Applier { public static <E> void apply(SearchFunction<E> f, Iterator<? extends E> i) { while (i.hasNext() && f.applyTo(i.next())) { } } private  Applier(); static void apply(SearchFunction<E> f, Iterator<? extends E> i);  }
@Test public void testSimple() { MyFunction f = new MyFunction(Integer.MAX_VALUE); List<Object> l = new ArrayList<>(); l.add(new Object()); l.add(new Object()); l.add(new Object()); Applier.apply(f, l.iterator()); assertEquals(l.size(), f.getNumCallbacks()); }
@Test public void testLimit() { MyFunction f = new MyFunction(2); List<Object> l = new ArrayList<>(); l.add(new Object()); l.add(new Object()); l.add(new Object()); Applier.apply(f, l.iterator()); assertEquals(2, f.getNumCallbacks()); }