use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method asLazy.
@Test
public void asLazy() {
BooleanIterable iterable = this.classUnderTest();
Assert.assertEquals(iterable.toBag(), iterable.asLazy().toBag());
Verify.assertInstanceOf(LazyBooleanIterable.class, iterable.asLazy());
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method appendString.
@Test
public void appendString() {
StringBuilder appendable = new StringBuilder();
this.newWith().appendString(appendable);
Assert.assertEquals("", appendable.toString());
this.newWith().appendString(appendable, "/");
Assert.assertEquals("", appendable.toString());
this.newWith().appendString(appendable, "[", "/", "]");
Assert.assertEquals("[]", appendable.toString());
StringBuilder appendable1 = new StringBuilder();
this.newWith(true).appendString(appendable1);
Assert.assertEquals("true", appendable1.toString());
StringBuilder appendable2 = new StringBuilder();
BooleanIterable iterable = this.newWith(true, false);
iterable.appendString(appendable2);
Assert.assertTrue("true, false".equals(appendable2.toString()) || "false, true".equals(appendable2.toString()));
StringBuilder appendable3 = new StringBuilder();
iterable.appendString(appendable3, "/");
Assert.assertTrue("true/false".equals(appendable3.toString()) || "false/true".equals(appendable3.toString()));
StringBuilder appendable4 = new StringBuilder();
iterable.appendString(appendable4, "[", ", ", "]");
Assert.assertEquals(iterable.toString(), appendable4.toString());
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method count.
@Test
public void count() {
Assert.assertEquals(2L, this.newWith(true, false, true).count(BooleanPredicates.isTrue()));
Assert.assertEquals(0L, this.newWith().count(BooleanPredicates.isFalse()));
BooleanIterable iterable = this.newWith(true, false, false, true, true, true);
Assert.assertEquals(4L, iterable.count(BooleanPredicates.isTrue()));
Assert.assertEquals(2L, iterable.count(BooleanPredicates.isFalse()));
Assert.assertEquals(6L, iterable.count(BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())));
BooleanIterable iterable1 = this.classUnderTest();
int size = iterable1.size();
int halfSize = size / 2;
Assert.assertEquals((size & 1) == 1 ? halfSize + 1 : halfSize, iterable1.count(BooleanPredicates.isTrue()));
Assert.assertEquals(halfSize, iterable1.count(BooleanPredicates.isFalse()));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method detectIfNone.
@Test
public void detectIfNone() {
BooleanIterable iterable = this.classUnderTest();
int size = iterable.size();
Assert.assertEquals(size < 2, iterable.detectIfNone(BooleanPredicates.isFalse(), true));
Assert.assertTrue(iterable.detectIfNone(BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()), true));
BooleanIterable iterable1 = this.newWith(true, true, true);
Assert.assertFalse(iterable1.detectIfNone(BooleanPredicates.isFalse(), false));
Assert.assertTrue(iterable1.detectIfNone(BooleanPredicates.isFalse(), true));
Assert.assertTrue(iterable1.detectIfNone(BooleanPredicates.isTrue(), false));
Assert.assertTrue(iterable1.detectIfNone(BooleanPredicates.isTrue(), true));
BooleanIterable iterable2 = this.newWith(false, false, false);
Assert.assertTrue(iterable2.detectIfNone(BooleanPredicates.isTrue(), true));
Assert.assertFalse(iterable2.detectIfNone(BooleanPredicates.isTrue(), false));
Assert.assertFalse(iterable2.detectIfNone(BooleanPredicates.isFalse(), true));
Assert.assertFalse(iterable2.detectIfNone(BooleanPredicates.isFalse(), false));
}
Aggregations