@Test public void collectFloatWithTarget() { FloatHashBag target = new FloatHashBag(); FloatHashBag result = this.newBag().collectFloat(Float::parseFloat, 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 collectFloat() { MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3)); Assert.assertEquals( FloatHashBag.newBagWith(1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f), integers.collectFloat(PrimitiveFunctions.unboxIntegerToFloat())); }
@Override public MutableFloatBag toBag() { return FloatHashBag.newBag(this); }