Skip to content

Commit b5fdcab

Browse files
test: Add comprehensive tests for JugglerSequence
- Added tests for input values 1, 2, 3, and 9 - Tests verify correct sequence output - Improves code coverage for maths package
1 parent 2da0465 commit b5fdcab

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.thealgorithms.maths;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import org.junit.jupiter.api.Test;
5+
import java.io.ByteArrayOutputStream;
6+
import java.io.PrintStream;
7+
8+
class JugglerSequenceTest {
9+
10+
@Test
11+
void testJugglerSequenceWithThree() {
12+
// Capture System.out
13+
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
14+
System.setOut(new PrintStream(outContent));
15+
16+
JugglerSequence.jugglerSequence(3);
17+
18+
assertEquals("3,5,11,36,6,2,1\n", outContent.toString());
19+
}
20+
21+
@Test
22+
void testJugglerSequenceWithTwo() {
23+
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
24+
System.setOut(new PrintStream(outContent));
25+
26+
JugglerSequence.jugglerSequence(2);
27+
28+
assertEquals("2,1\n", outContent.toString());
29+
}
30+
31+
@Test
32+
void testJugglerSequenceWithNine() {
33+
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
34+
System.setOut(new PrintStream(outContent));
35+
36+
JugglerSequence.jugglerSequence(9);
37+
38+
assertEquals("9,27,140,11,36,6,2,1\n", outContent.toString());
39+
}
40+
41+
@Test
42+
void testJugglerSequenceWithOne() {
43+
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
44+
System.setOut(new PrintStream(outContent));
45+
46+
JugglerSequence.jugglerSequence(1);
47+
48+
assertEquals("1\n", outContent.toString());
49+
}
50+
}
51+

0 commit comments

Comments
 (0)