@Override @Test default void RichIterable_selectInstancesOf() { // Must test with two classes that are mutually Comparable SortedBag<A> numbers = this.<A>newWith( new C(4.0), new C(4.0), new C(4.0), new C(4.0), new B(3), new B(3), new B(3), new C(2.0), new C(2.0), new B(1)); assertEquals( this.<B>getExpectedFiltered(new B(3), new B(3), new B(3), new B(1)), numbers.selectInstancesOf(B.class)); assertEquals( this.getExpectedFiltered( new C(4.0), new C(4.0), new C(4.0), new C(4.0), new B(3), new B(3), new B(3), new C(2.0), new C(2.0), new B(1)), numbers.selectInstancesOf(A.class)); }
@Override @Test default void Bag_occurrencesOf() { SortedBag<Integer> bag = this.newWith(3, 3, 3, 2, 2, 1); assertEquals(0, bag.occurrencesOf(0)); assertEquals(1, bag.occurrencesOf(1)); assertEquals(2, bag.occurrencesOf(2)); assertEquals(3, bag.occurrencesOf(3)); }
@Test default void SortedBag_forEachWith() { SortedBag<Integer> bag = this.newWith(3, 3, 3, 2, 2, 1); MutableList<Integer> result = Lists.mutable.with(); bag.forEachWith( (argument1, argument2) -> { result.add(argument1); result.add(argument2); }, 0); assertEquals(Lists.immutable.with(3, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0), result); }
@Override @Test default void Bag_sizeDistinct() { SortedBag<Integer> bag = this.newWith(3, 3, 3, 2, 2, 1); assertEquals(3, bag.sizeDistinct()); }