File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
src/test/java/com/thealgorithms/stacks Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .stacks ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
5
+
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ class ReverseStringUsingStackTest {
9
+
10
+ @ Test
11
+ void testRegularString () {
12
+ assertEquals ("olleh" , ReverseStringUsingStack .reverse ("hello" ));
13
+ }
14
+
15
+ @ Test
16
+ void testEmptyString () {
17
+ assertEquals ("" , ReverseStringUsingStack .reverse ("" ));
18
+ }
19
+
20
+ @ Test
21
+ void testPalindromeString () {
22
+ assertEquals ("madam" , ReverseStringUsingStack .reverse ("madam" ));
23
+ }
24
+
25
+ @ Test
26
+ void testSpecialCharacters () {
27
+ assertEquals ("#@!321cba" , ReverseStringUsingStack .reverse ("abc123!@#" ));
28
+ }
29
+
30
+ @ Test
31
+ void testSingleCharacter () {
32
+ assertEquals ("x" , ReverseStringUsingStack .reverse ("x" ));
33
+ }
34
+
35
+ @ Test
36
+ void testWhitespaceHandling () {
37
+ assertEquals ("dlroW olleH" , ReverseStringUsingStack .reverse ("Hello World" ));
38
+ }
39
+
40
+ @ Test
41
+ void testNullInput () {
42
+ assertThrows (NullPointerException .class , () -> { ReverseStringUsingStack .reverse (null ); });
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments