mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
tests: Levenshtein Distance (dynamic programming solution) (#1114)
This commit is contained in:
19
Dynamic-Programming/tests/LevenshteinDistance.test.js
Normal file
19
Dynamic-Programming/tests/LevenshteinDistance.test.js
Normal file
@ -0,0 +1,19 @@
|
||||
import { calculateLevenshteinDp } from '../LevenshteinDistance'
|
||||
|
||||
test('Should return the distance counting additions and removals', () => {
|
||||
const from = 'kitten'
|
||||
const to = 'sitting'
|
||||
expect(calculateLevenshteinDp(from, to)).toBe(3)
|
||||
})
|
||||
|
||||
test('Should return the distance based on replacements in the middle of the strings', () => {
|
||||
const from = 'book'
|
||||
const to = 'back'
|
||||
expect(calculateLevenshteinDp(from, to)).toBe(2)
|
||||
})
|
||||
|
||||
test('Should return the distance for strings with different length', () => {
|
||||
const from = 'sunday'
|
||||
const to = 'saturday'
|
||||
expect(calculateLevenshteinDp(from, to)).toBe(3)
|
||||
})
|
Reference in New Issue
Block a user