@Override @Test public void select() { BooleanIterable iterable = this.classUnderTest(); Verify.assertSize(1, iterable.select(BooleanPredicates.isFalse())); Verify.assertSize(2, iterable.select(BooleanPredicates.isTrue())); }
@Test public void detectIfNone() { MutableBooleanCollection collection = this.classUnderTest(); Assert.assertFalse(collection.detectIfNone(BooleanPredicates.isFalse(), true)); Assert.assertTrue( collection.detectIfNone( BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()), true)); }
@Test public void detectIfNone() { Assert.assertTrue(this.map.detectIfNone(BooleanPredicates.isTrue(), false)); Assert.assertFalse(this.map.detectIfNone(BooleanPredicates.isFalse(), true)); Assert.assertFalse( this.newWithKeysValues("0", true, "1", true) .detectIfNone( BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()), false)); }
@Test public void noneSatisfy() { Assert.assertFalse(this.map.noneSatisfy(BooleanPredicates.isTrue())); Assert.assertFalse(this.map.noneSatisfy(BooleanPredicates.isFalse())); Assert.assertTrue( this.map.noneSatisfy( BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); Assert.assertFalse( this.map.noneSatisfy( BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); }
@Test public void count() { Assert.assertEquals(2L, this.map.count(BooleanPredicates.isTrue())); Assert.assertEquals(1L, this.map.count(BooleanPredicates.isFalse())); Assert.assertEquals( 3L, this.map.count( BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); Assert.assertEquals( 0L, this.map.count( BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); }
@Test public void reject() { Assert.assertEquals( BooleanHashBag.newBagWith(false), this.map.reject(BooleanPredicates.isTrue()).toBag()); Assert.assertEquals( BooleanHashBag.newBagWith(true, true), this.map.reject(BooleanPredicates.isFalse()).toBag()); Assert.assertEquals( new BooleanHashBag(), this.map .reject(BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())) .toBag()); Assert.assertEquals( BooleanHashBag.newBagWith(true, true, false), this.map .reject(BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())) .toBag()); Assert.assertEquals( this.newWithKeysValues("1", true, "2", false), this.map.reject( new ObjectBooleanPredicate<String>() { public boolean accept(String object, boolean value) { return (Integer.parseInt(object) & 1) == 0 && value; } })); Assert.assertEquals( this.newWithKeysValues("0", true, "1", true), this.map.reject( new ObjectBooleanPredicate<String>() { public boolean accept(String object, boolean value) { return (Integer.parseInt(object) & 1) == 0 && !value; } })); Assert.assertEquals( this.newWithKeysValues("0", true, "1", true, "2", false), this.map.reject( new ObjectBooleanPredicate<String>() { public boolean accept(String object, boolean value) { return (Integer.parseInt(object) & 1) != 0 && !value; } })); }
public BooleanHashSet reject(BooleanPredicate predicate) { return this.select(BooleanPredicates.not(predicate)); }
@Test public void reject() { MutableBooleanCollection collection = this.classUnderTest(); Verify.assertSize(1, collection.reject(BooleanPredicates.isTrue())); Verify.assertSize(2, collection.reject(BooleanPredicates.isFalse())); }
@Test public void noneSatisfy() { Assert.assertTrue(this.newWith(true, true).noneSatisfy(BooleanPredicates.isFalse())); Assert.assertFalse(this.newWith(true, true).noneSatisfy(BooleanPredicates.isTrue())); }
@Test public void anySatisfy() { Assert.assertTrue(this.newWith(true).anySatisfy(BooleanPredicates.isTrue())); Assert.assertFalse(this.newWith(false).anySatisfy(BooleanPredicates.isTrue())); }
@Test public void count() { Assert.assertEquals(2L, this.newWith(true, false, true).count(BooleanPredicates.isTrue())); }