use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class AbstractBooleanIterableTestCase method contains.
@Test
public void contains() {
BooleanIterable emptyCollection = this.newWith();
Assert.assertFalse(emptyCollection.contains(true));
Assert.assertFalse(emptyCollection.contains(false));
BooleanIterable booleanIterable = this.classUnderTest();
int size = booleanIterable.size();
Assert.assertEquals(size >= 1, booleanIterable.contains(true));
Assert.assertEquals(size >= 2, booleanIterable.contains(false));
Assert.assertFalse(this.newWith(true, true, true).contains(false));
Assert.assertFalse(this.newWith(false, false, false).contains(true));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class SynchronizedBooleanIterableTest method booleanIterator.
@Override
@Test
public void booleanIterator() {
BooleanIterable iterable = this.newWith(true, true, false, false);
BooleanArrayList list = BooleanArrayList.newListWith(true, true, false, false);
BooleanIterator iterator = iterable.booleanIterator();
for (int i = 0; i < 4; i++) {
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(list.remove(iterator.next()));
}
Verify.assertEmpty(list);
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class MapIterableTestCase method collectBoolean.
@Test
public void collectBoolean() {
MapIterable<String, String> map = this.newMapWithKeysValues("One", "true", "Two", "nah", "Three", "TrUe");
BooleanIterable actual = map.collectBoolean(Boolean::parseBoolean);
Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true), actual.toBag());
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ObjectBooleanHashMapValuesTestCase method appendString.
@Override
@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()));
}
use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.
the class ImmutableBooleanEmptyListTest method select.
@Override
@Test
public void select() {
super.select();
BooleanIterable iterable = this.classUnderTest();
Verify.assertEmpty(iterable.select(BooleanPredicates.isTrue()));
BooleanIterable booleanIterable = iterable.select(BooleanPredicates.isFalse());
Verify.assertEmpty(booleanIterable);
Assert.assertSame(iterable, booleanIterable);
}
Aggregations