-
Notifications
You must be signed in to change notification settings - Fork 0
/
LengthOfLongestSubstring.test.java
35 lines (28 loc) · 1.24 KB
/
LengthOfLongestSubstring.test.java
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
34
35
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class LengthOfLongestSubstringTest {
@Test
public void testLengthOfLongestSubstring_General() {
assertEquals(5, LengthOfLongestSubstring.lengthOfLongestSubstring("eadiedniweif"));
assertEquals(3, LengthOfLongestSubstring.lengthOfLongestSubstring("abcabcbb"));
assertEquals(1, LengthOfLongestSubstring.lengthOfLongestSubstring("bbbbb"));
assertEquals(3, LengthOfLongestSubstring.lengthOfLongestSubstring("pwwkew"));
}
@Test
public void testLengthOfLongestSubstring_Empty() {
assertEquals(0, LengthOfLongestSubstring.lengthOfLongestSubstring(""));
}
@Test
public void testLengthOfLongestSubstring_SingleCharacter() {
assertEquals(1, LengthOfLongestSubstring.lengthOfLongestSubstring("a"));
}
@Test
public void testLengthOfLongestSubstring_TwoDistinctCharacters() {
assertEquals(2, LengthOfLongestSubstring.lengthOfLongestSubstring("ab"));
}
@Test
public void testLengthOfLongestSubstring_TwoSameCharacters() {
assertEquals(1, LengthOfLongestSubstring.lengthOfLongestSubstring("aa"));
}
// ... Additional test cases as necessary ...
}