1 package uk.co.jezuk.mango; 2 3 import junit.framework.*; 4 5 public class BoundedIteratorTest extends TestCase 6 { 7 java.util.List list; 8 9 public BoundedIteratorTest(String name) { super(name); } 10 public static Test suite() { return new TestSuite(BoundedIteratorTest.class); } 11 12 protected void setUp() 13 { 14 list = new java.util.ArrayList (); 15 for(int i = 0; i < 10; ++i) 16 list.add(new Integer (i)); 17 } 19 public void test1() 20 { 21 java.util.Iterator bi = Iterators.BoundedIterator(list, 2, 5); 22 assertEquals(true, bi.hasNext()); 23 assertEquals(new Integer (2), bi.next()); 24 assertEquals(true, bi.hasNext()); 25 assertEquals(new Integer (3), bi.next()); 26 assertEquals(true, bi.hasNext()); 27 assertEquals(new Integer (4), bi.next()); 28 assertEquals(false, bi.hasNext()); 29 } 31 public void test2() 32 { 33 java.util.Iterator bi = Iterators.BoundedIterator(list, 8, 12); 34 assertEquals(true, bi.hasNext()); 35 assertEquals(new Integer (8), bi.next()); 36 assertEquals(true, bi.hasNext()); 37 assertEquals(new Integer (9), bi.next()); 38 assertEquals(false, bi.hasNext()); 39 } 41 public void test3() 42 { 43 java.util.Iterator bi = Iterators.BoundedIterator(list, 12, 12); 44 assertEquals(false, bi.hasNext()); 45 } 47 public void test4() 48 { 49 java.util.Iterator bi = Iterators.BoundedIterator(list.iterator(), 2, 5); 50 assertEquals(true, bi.hasNext()); 51 assertEquals(new Integer (2), bi.next()); 52 assertEquals(true, bi.hasNext()); 53 assertEquals(new Integer (3), bi.next()); 54 assertEquals(true, bi.hasNext()); 55 assertEquals(new Integer (4), bi.next()); 56 assertEquals(false, bi.hasNext()); 57 } 59 public void test5() 60 { 61 java.util.Iterator bi = Iterators.BoundedIterator(list.iterator(), 8, 12); 62 assertEquals(true, bi.hasNext()); 63 assertEquals(new Integer (8), bi.next()); 64 assertEquals(true, bi.hasNext()); 65 assertEquals(new Integer (9), bi.next()); 66 assertEquals(false, bi.hasNext()); 67 } 69 public void test6() 70 { 71 java.util.Iterator bi = Iterators.BoundedIterator(list.iterator(), 12, 12); 72 assertEquals(false, bi.hasNext()); 73 } } | Popular Tags |