@Test public void collectIntWithTarget() { IntHashBag target = new IntHashBag(); IntHashBag result = this.newBag().collectInt(Integer::parseInt, target); Assert.assertSame("Target sent as parameter not returned", target, result); Assert.assertEquals(this.numKeys(), result.sizeDistinct()); for (int i = 1; i <= this.numKeys(); i++) { Assert.assertEquals(i, result.occurrencesOf(i)); } }
@Override @Test public void collectInt() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( IntHashBag.newBagWith(1, 2, 2, 3, 3, 3), integers.collectInt(PrimitiveFunctions.unboxIntegerToInt())); }