Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import common.TestUtil;
- import junit.framework.TestCase;
- public class MysteriousPatternTest extends TestCase {
- public void testMysteriousPattern() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- MysteriousPattern.main(null);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "35 28 21 14 7",
- "20 15 10 5",
- "9 5 3",
- "2 1",
- "0"),
- systemOutput);
- }
- public void testRaviShankarOjhaExample() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaExample.main(null);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "35 28 21 14 7 ",
- "",
- "20 15 10 5 ",
- "",
- "9 6 3 ", // but "9 5 3" must be "9 6 3"
- "",
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactoredExample() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.main(null);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "35 28 21 14 7 ",
- "20 15 10 5 ",
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues13() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(13);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "104 91 78 65 52 39 26 13 ",
- "77 66 55 44 33 22 11 ",
- "54 45 36 27 18 9 ",
- "35 28 21 14 7 ",
- "20 15 10 5 ",
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues11() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(11);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "77 66 55 44 33 22 11 ",
- "54 45 36 27 18 9 ",
- "35 28 21 14 7 ",
- "20 15 10 5 ",
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues9() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(9);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "54 45 36 27 18 9 ",
- "35 28 21 14 7 ",
- "20 15 10 5 ",
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues7() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(7);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "35 28 21 14 7 ",
- "20 15 10 5 ",
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues5() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(5);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "20 15 10 5 ",
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues3() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(3);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "9 5 3 ", // Might make more sense as "9 6 3"
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues1() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(1);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "2 1 ",
- "0 "),
- systemOutput);
- }
- public void testRaviShankarOjhaRefactored_printValues0() throws Exception {
- final String systemOutput = TestUtil.captureSystemOut(() -> {
- RaviShankarOjhaRefactored.printValues(0);
- });
- assertEquals("Expected System output;", TestUtil.multipleLines(
- "0 "),
- systemOutput);
- }
- }
Add Comment
Please, Sign In to add comment