mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
refactor: RemoveDuplicateFromString
(#5387)
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
package com.thealgorithms.others;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class RemoveDuplicateFromStringTest {
|
||||
|
||||
@Test
|
||||
void testEmptyString() {
|
||||
assertEquals("", RemoveDuplicateFromString.removeDuplicate(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullString() {
|
||||
assertNull(RemoveDuplicateFromString.removeDuplicate(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSingleCharacterString() {
|
||||
assertEquals("a", RemoveDuplicateFromString.removeDuplicate("a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringWithNoDuplicates() {
|
||||
assertEquals("abc", RemoveDuplicateFromString.removeDuplicate("abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringWithDuplicates() {
|
||||
assertEquals("abcd", RemoveDuplicateFromString.removeDuplicate("aabbbccccddddd"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringWithAllSameCharacters() {
|
||||
assertEquals("a", RemoveDuplicateFromString.removeDuplicate("aaaaa"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStringWithMixedCase() {
|
||||
assertEquals("abAB", RemoveDuplicateFromString.removeDuplicate("aabABAB"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user