Skip to content

Commit b94bcc8

Browse files
Add files via upload
1 parent 9bec25d commit b94bcc8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Fibonacci/FibonacciOutputTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import static org.junit.Assert.*;
2+
import java.io.*;
3+
import org.junit.Test;
4+
5+
public class FibonacciOutputTest {
6+
7+
@Test
8+
public void testConsoleOutputFibonacci() {
9+
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
10+
PrintStream originalOut = System.out;
11+
System.setOut(new PrintStream(outContent));
12+
13+
Fibonacci_series.main(new String[]{});
14+
15+
System.setOut(originalOut);
16+
17+
String expectedOutput = "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181";
18+
String actualOutput = outContent.toString().trim();
19+
20+
assertEquals(expectedOutput, actualOutput);
21+
}
22+
}

0 commit comments

Comments
 (0)