mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 22:43:30 +08:00
Fix ArrayIndexOutOfBoundsException in LevenshteinDistance (#3871)
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class LevenshteinDistanceTests {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"dog,cat,3", "sunday,saturday,3", "cat,cats,1", "rain,train,1"})
|
||||
void levenshteinDistanceTest(String str1, String str2, int distance) {
|
||||
int result = LevenshteinDistance.calculateLevenshteinDistance(str1, str2);
|
||||
assertEquals(distance, result);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user