PagerTestpublic class PagerTest extends TestCase
Constructors Summary |
---|
public PagerTest(String name)
super(name);
|
Methods Summary |
---|
public static void | main(java.lang.String[] args)
if (args.length == 0){
junit.textui.TestRunner.run(PagerTest.class);
} else {
junit.textui.TestRunner.run(makeSuite(args));
}
| private static junit.framework.TestSuite | makeSuite(java.lang.String[] args)
final TestSuite ts = new TestSuite();
for (int i = 0; i < args.length; i++){
ts.addTest(new PagerTest(args[i]));
}
return ts;
| private void | nyi()
fail("Not Yet Implemented");
| protected void | setUp()
stdout = new Pipe();
| protected void | tearDown()
| public void | testHasNext()
final Pager m = new Pager(2, new StringReader("1\n2\n3"),
stdout.getWriter());
assertTrue("Didn't expect anything in the output!",
!stdout.ready());
m.nextPage();
assertTrue(m.hasNext());
m.nextPage();
assertTrue(!m.hasNext());
| public void | testMultiplePages()
final Pager m = new Pager(2, new StringReader("1\n2\n3\n4\n5\n6\n7"), stdout.getWriter());
assertTrue("Didn't expect anything in the output!", !stdout.ready());
m.nextPage();
assertTrue("Expected something on the output!", stdout.ready());
assertEquals("1", stdout.readLine());
assertEquals("2", stdout.readLine());
assertTrue("Expected end of page 1", !stdout.ready());
m.nextPage();
assertTrue("Expected page 2 to be ready", stdout.ready());
assertEquals("3", stdout.readLine());
assertEquals("4", stdout.readLine());
assertTrue("Expected to be waiting for page 3", !stdout.ready());
m.nextPage();
assertEquals("5", stdout.readLine());
assertEquals("6", stdout.readLine());
assertTrue("Expected to be waiting for page 4", !stdout.ready());
m.nextPage();
assertEquals("7", stdout.readLine());
assertTrue("Expected end of page 4", !stdout.ready());
| public void | testNegativeLinesPerPage()
final Pager m = new Pager(-1, new StringReader("1\n2\n3"),
stdout.getWriter());
m.nextPage();
assertEquals("1", stdout.readLine());
assertEquals("2", stdout.readLine());
assertEquals("3", stdout.readLine());
assertTrue("Output should no longer be ready", !stdout.ready());
| public void | testSinglePage()
final Pager m = new Pager(2, new StringReader("1\n2\n"), stdout.getWriter());
assertTrue("Didn't expect anything in the output!", !stdout.ready());
m.nextPage();
assertTrue("Expected something on the output!", stdout.ready());
assertEquals("1", stdout.readLine());
assertEquals("2", stdout.readLine());
assertTrue("Expected no more output", !stdout.ready());
| public void | testZeroLengthPage()
final Pager m = new Pager(0, new StringReader("1\n2\n3\n4\n5\n6\n7"),
stdout.getWriter());
assertTrue("Didn't expect anything in the output!",
!stdout.ready());
m.nextPage();
assertTrue("Didn't expect anything in the output!",
!stdout.ready());
|
|