forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongestNonRepetitiveSubstringTest.java
More file actions
22 lines (17 loc) · 1006 Bytes
/
LongestNonRepetitiveSubstringTest.java
File metadata and controls
22 lines (17 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.thealgorithms.strings;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class LongestNonRepetitiveSubstringTest {
private static Stream<Arguments> provideTestCases() {
return Stream.of(Arguments.of("", 0), Arguments.of("a", 1), Arguments.of("abcde", 5), Arguments.of("aaaaa", 1), Arguments.of("abca", 3), Arguments.of("abcdeabc", 5), Arguments.of("a1b2c3", 6), Arguments.of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", 62),
Arguments.of("aabb", 2), Arguments.of("abcdefghijabc", 10));
}
@ParameterizedTest
@MethodSource("provideTestCases")
void testLengthOfLongestSubstring(String input, int expectedLength) {
assertEquals(expectedLength, LongestNonRepetitiveSubstring.lengthOfLongestSubstring(input));
}
}