1 21 package com.db4o.db4ounit.common.foundation; 22 23 import com.db4o.foundation.ArrayIterator4; 24 25 import db4ounit.*; 26 27 28 public class ArrayIterator4TestCase implements TestCase { 29 30 public void testEmptyArray() { 31 assertExhausted(new ArrayIterator4(new Object [0])); 32 } 33 34 public void testArray() { 35 ArrayIterator4 i = new ArrayIterator4(new Object [] { "foo", "bar" }); 36 Assert.isTrue(i.moveNext()); 37 Assert.areEqual("foo", i.current()); 38 39 Assert.isTrue(i.moveNext()); 40 Assert.areEqual("bar", i.current()); 41 42 assertExhausted(i); 43 } 44 45 private void assertExhausted(final ArrayIterator4 i) { 46 Assert.isFalse(i.moveNext()); 47 Assert.expect(ArrayIndexOutOfBoundsException .class, new CodeBlock(){ 48 public void run() throws Exception { 49 System.out.println(i.current()); 50 } 51 }); 52 } 53 54 } 55 | Popular Tags |