@Test public void rejectOnFromToInterval() { Interval interval = Interval.oneTo(5); Assert.assertEquals( FastList.newListWith(1, 3, 5), interval.reject(IntegerPredicates.isEven()).toList()); Assert.assertEquals( FastList.newListWith(5, 3, 1), interval.reverseThis().reject(IntegerPredicates.isEven()).toList()); }
@Test public void select() { Interval interval = Interval.fromTo(10, -10).by(-5); MutableList<Integer> expected = FastList.newListWith(10, 0, -10); Assert.assertEquals(expected, interval.select(IntegerPredicates.isEven()).toList()); Assert.assertEquals( expected, interval.select(IntegerPredicates.isEven(), FastList.<Integer>newList())); }
@Test public void selectOnFromToInterval() { Interval interval = Interval.oneTo(5); Assert.assertEquals( FastList.newListWith(2, 4), interval.select(IntegerPredicates.isEven()).toList()); Assert.assertEquals( FastList.newListWith(4, 2), interval.reverseThis().select(IntegerPredicates.isEven()).toList()); }
@Test public void testComparatorConstructors() { MutableSortedBagMultimap<Boolean, Integer> revMap = TreeBagMultimap.newMultimap(Collections.reverseOrder()); for (int i = 1; i < 10; ++i) { revMap.put(IntegerPredicates.isOdd().accept(i), i); } Verify.assertSize(2, revMap.keysView().toList()); Verify.assertSortedBagsEqual( TreeBag.newBagWith(Collections.reverseOrder(), 9, 7, 5, 3, 1), revMap.get(Boolean.TRUE)); Verify.assertSortedBagsEqual( TreeBag.newBagWith(Collections.reverseOrder(), 8, 6, 4, 2), revMap.get(Boolean.FALSE)); MutableSortedBagMultimap<Boolean, Integer> revMap2 = TreeBagMultimap.newMultimap(revMap); Verify.assertMapsEqual(revMap2.toMap(), revMap.toMap()); Verify.assertSortedBagsEqual( TreeBag.newBagWith(Collections.reverseOrder(), 9, 7, 5, 3, 1), revMap2.get(Boolean.TRUE)); }