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