Ejemplo n.º 1
0
 @Test
 public void collectByteWithTarget() {
   ByteHashBag target = new ByteHashBag();
   ByteHashBag result = this.newBag().collectByte(Byte::parseByte, 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((byte) i));
   }
 }
Ejemplo n.º 2
0
 @Override
 @Test
 public void collectByte() {
   MutableBag<Integer> integers = UnmodifiableBag.of(HashBag.newBagWith(1, 2, 2, 3, 3, 3));
   Assert.assertEquals(
       ByteHashBag.newBagWith((byte) 1, (byte) 2, (byte) 2, (byte) 3, (byte) 3, (byte) 3),
       integers.collectByte(PrimitiveFunctions.unboxIntegerToByte()));
 }