Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import junit.framework.TestCase;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.io.PrintStream;
- public class NumberRectangleTest extends TestCase {
- public void test() throws IOException {
- final PrintStream oldSystemOut = System.out;
- final OutputStream outputStream = new ByteArrayOutputStream();
- System.setOut(new PrintStream(outputStream));
- try {
- YourMainClassNameHere.main(new String[0]);
- } finally {
- System.setOut(oldSystemOut);
- }
- outputStream.flush();
- outputStream.close();
- final String NL = System.getProperty("line.separator");
- assertEquals("" +
- "1 5 9" + NL +
- "2 6 10" + NL +
- "3 7 11" + NL +
- "4 8 12" + NL,
- outputStream.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement