| 1 21 package com.db4o.db4ounit.common.foundation; 22 23 import com.db4o.foundation.*; 24 25 import db4ounit.*; 26 27 30 public class IteratorsTestCase implements TestCase { 31 32 public void testMap() { 33 final int[] array = new int[] { 1, 2, 3 }; 34 final Collection4 args = new Collection4(); 35 final Iterator4 iterator = Iterators.map( 36 IntArrays4.newIterator(array), 37 new Function4() { 38 public Object apply(Object arg) { 39 args.add(arg); 40 return new Integer (((Integer )arg).intValue()*2); 41 } 42 } 43 ); 44 Assert.isNotNull(iterator); 45 Assert.areEqual(0, args.size()); 46 47 for (int i=0; i<array.length; ++i) { 48 Assert.isTrue(iterator.moveNext()); 49 Assert.areEqual(i+1, args.size()); 50 Assert.areEqual(new Integer (array[i]*2), iterator.current()); 51 } 52 } 53 54 } 55 | Popular Tags |