mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Add longest substring (#6007)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.thealgorithms.slidingwindow;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for the LongestSubstringWithoutRepeatingCharacters class.
|
||||
*
|
||||
* @author (https://github.com/Chiefpatwal)
|
||||
*/
|
||||
public class LongestSubstringWithoutRepeatingCharactersTest {
|
||||
|
||||
@Test
|
||||
public void testLengthOfLongestSubstring() {
|
||||
// Test cases for the lengthOfLongestSubstring method
|
||||
assertEquals(3, LongestSubstringWithoutRepeatingCharacters.lengthOfLongestSubstring("abcabcbb"));
|
||||
assertEquals(1, LongestSubstringWithoutRepeatingCharacters.lengthOfLongestSubstring("bbbbb"));
|
||||
assertEquals(3, LongestSubstringWithoutRepeatingCharacters.lengthOfLongestSubstring("pwwkew"));
|
||||
assertEquals(0, LongestSubstringWithoutRepeatingCharacters.lengthOfLongestSubstring(""));
|
||||
assertEquals(5, LongestSubstringWithoutRepeatingCharacters.lengthOfLongestSubstring("abcde"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user