mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 08:16:50 +08:00
22 lines
649 B
JavaScript
22 lines
649 B
JavaScript
import { hammingDistance } from '../HammingDistance'
|
|
|
|
test('should throw an error when trying to compare the strings of different length', () => {
|
|
const compareStringsOfDifferentLength = () => {
|
|
hammingDistance('abc', 'abcd')
|
|
}
|
|
|
|
expect(compareStringsOfDifferentLength).toThrowError()
|
|
})
|
|
|
|
test('should calculate difference between two strings', () => {
|
|
expect(hammingDistance('a', 'a')).toBe(0)
|
|
})
|
|
|
|
test('should calculate difference between two strings', () => {
|
|
expect(hammingDistance('abc', 'add')).toBe(2)
|
|
})
|
|
|
|
test('should calculate difference between two strings', () => {
|
|
expect(hammingDistance('1011101', '1001001')).toBe(2)
|
|
})
|