forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongestCommonSubstringTest.java
More file actions
33 lines (28 loc) · 1.08 KB
/
Copy pathLongestCommonSubstringTest.java
File metadata and controls
33 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.thealgorithms.strings;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
public class LongestCommonSubstringTest {
private record TestData(String a, String b, String expected) {
}
private static Stream<TestData> provideTestCases() {
return Stream.of(
new TestData(null, "abc", ""),
new TestData("abc", null, ""),
new TestData("", "abc", ""),
new TestData("abc", "", ""),
new TestData("abcdef", "zcdemf", "cde"),
new TestData("abc", "abc", "abc"),
new TestData("abc", "xyz", ""),
new TestData("abcdef", "cdefgh", "cdef"),
new TestData("a", "a", "a")
);
}
@ParameterizedTest
@MethodSource("provideTestCases")
void testLongestCommonSubstring(TestData testData) {
Assertions.assertEquals(testData.expected(),
LongestCommonSubstring.longestCommonSubstring(testData.a(), testData.b()));
}
}