use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method allSatisfy.
@Test
public void allSatisfy() {
BooleanIterable booleanIterable = this.classUnderTest();
int size = booleanIterable.size();
Assert.assertEquals(size <= 1, booleanIterable.allSatisfy(BooleanPredicates.isTrue()));
Assert.assertEquals(size == 0, booleanIterable.allSatisfy(BooleanPredicates.isFalse()));
Assert.assertTrue(this.newWith().allSatisfy(BooleanPredicates.isTrue()));
Assert.assertTrue(this.newWith().allSatisfy(BooleanPredicates.isFalse()));
Assert.assertTrue(this.newWith(false, false).allSatisfy(BooleanPredicates.isFalse()));
Assert.assertFalse(this.newWith(true, false).allSatisfy(BooleanPredicates.isTrue()));
Assert.assertTrue(this.newWith(true, true, true).allSatisfy(BooleanPredicates.isTrue()));
Assert.assertTrue(this.newWith(false, false, false).allSatisfy(BooleanPredicates.isFalse()));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method iterator_throws_non_empty_collection.
@Test(expected = NoSuchElementException.class)
public void iterator_throws_non_empty_collection() {
BooleanIterable iterable = this.newWith(true, true, true);
BooleanIterator iterator = iterable.booleanIterator();
while (iterator.hasNext()) {
Assert.assertTrue(iterator.next());
}
iterator.next();
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method anySatisfy.
@Test
public void anySatisfy() {
BooleanIterable booleanIterable = this.classUnderTest();
int size = booleanIterable.size();
Assert.assertEquals(size >= 1, booleanIterable.anySatisfy(BooleanPredicates.isTrue()));
Assert.assertEquals(size >= 2, booleanIterable.anySatisfy(BooleanPredicates.isFalse()));
Assert.assertFalse(this.newWith(true, true).anySatisfy(BooleanPredicates.isFalse()));
Assert.assertFalse(this.newWith().anySatisfy(BooleanPredicates.isFalse()));
Assert.assertFalse(this.newWith().anySatisfy(BooleanPredicates.isTrue()));
Assert.assertTrue(this.newWith(true).anySatisfy(BooleanPredicates.isTrue()));
Assert.assertFalse(this.newWith(false).anySatisfy(BooleanPredicates.isTrue()));
Assert.assertTrue(this.newWith(false, false, false).anySatisfy(BooleanPredicates.isFalse()));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method containsAllArray.
@Test
public void containsAllArray() {
BooleanIterable iterable = this.classUnderTest();
int size = iterable.size();
Assert.assertEquals(size >= 1, iterable.containsAll(true));
Assert.assertEquals(size >= 2, iterable.containsAll(true, false, true));
Assert.assertEquals(size >= 2, iterable.containsAll(true, false));
Assert.assertEquals(size >= 1, iterable.containsAll(true, true));
Assert.assertEquals(size >= 2, iterable.containsAll(false, false));
BooleanIterable emptyCollection = this.newWith();
Assert.assertFalse(emptyCollection.containsAll(true));
Assert.assertFalse(emptyCollection.containsAll(false));
Assert.assertFalse(emptyCollection.containsAll(false, true, false));
Assert.assertFalse(this.newWith(true, true).containsAll(false, true, false));
BooleanIterable trueCollection = this.newWith(true, true, true, true);
Assert.assertFalse(trueCollection.containsAll(true, false));
BooleanIterable falseCollection = this.newWith(false, false, false, false);
Assert.assertFalse(falseCollection.containsAll(true, false));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method injectInto.
@Test
public void injectInto() {
BooleanIterable iterable = this.newWith(true, false, true);
MutableInteger result = iterable.injectInto(new MutableInteger(0), (object, value) -> object.add(value ? 1 : 0));
Assert.assertEquals(new MutableInteger(2), result);
}
Aggregations