Skip to content

Commit 193a8d7

Browse files
test: add JUnit tests for StringRotation
1 parent ff9573a commit 193a8d7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.thealgorithms.strings;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
import org.junit.jupiter.api.Test;
5+
6+
public class StringRotationTest {
7+
8+
@Test
9+
void testValidRotation() {
10+
assertTrue(StringRotation.isRotation("waterbottle", "erbottlewat"));
11+
}
12+
13+
@Test
14+
void testInvalidRotation() {
15+
assertFalse(StringRotation.isRotation("hello", "world"));
16+
}
17+
18+
@Test
19+
void testDifferentLengths() {
20+
assertFalse(StringRotation.isRotation("abc", "abcd"));
21+
}
22+
23+
@Test
24+
void testNullInput() {
25+
assertFalse(StringRotation.isRotation(null, "abc"));
26+
assertFalse(StringRotation.isRotation("abc", null));
27+
}
28+
}

0 commit comments

Comments
 (0)