Search in sources :

Example 16 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class AbstractBooleanIterableTestCase method makeString.

@Test
public void makeString() {
    Assert.assertEquals("true", this.newWith(true).makeString("/"));
    Assert.assertEquals("", this.newWith().makeString());
    Assert.assertEquals("", this.newWith().makeString("/"));
    Assert.assertEquals("[]", this.newWith().makeString("[", "/", "]"));
    BooleanIterable iterable = this.newWith(true, false);
    Assert.assertTrue("true, false".equals(iterable.makeString()) || "false, true".equals(iterable.makeString()));
    Assert.assertTrue(iterable.makeString("/"), "true/false".equals(iterable.makeString("/")) || "false/true".equals(iterable.makeString("/")));
    Assert.assertTrue(iterable.makeString("[", "/", "]"), "[true/false]".equals(iterable.makeString("[", "/", "]")) || "[false/true]".equals(iterable.makeString("[", "/", "]")));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Test(org.junit.Test)

Example 17 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class AbstractBooleanIterableTestCase method containsAllIterable.

@Test
public void containsAllIterable() {
    BooleanIterable emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.containsAll(new BooleanArrayList()));
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(false)));
    BooleanIterable booleanIterable = this.classUnderTest();
    int size = booleanIterable.size();
    Assert.assertTrue(booleanIterable.containsAll(new BooleanArrayList()));
    Assert.assertEquals(size >= 1, booleanIterable.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertEquals(size >= 2, booleanIterable.containsAll(BooleanArrayList.newListWith(false)));
    Assert.assertEquals(size >= 2, booleanIterable.containsAll(BooleanArrayList.newListWith(true, false)));
    BooleanIterable iterable = this.newWith(true, true, false, false, false);
    Assert.assertTrue(iterable.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertTrue(iterable.containsAll(BooleanArrayList.newListWith(false)));
    Assert.assertTrue(iterable.containsAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertTrue(iterable.containsAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertTrue(iterable.containsAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertTrue(iterable.containsAll(BooleanArrayList.newListWith(true, false, true)));
    Assert.assertFalse(this.newWith(true, true).containsAll(BooleanArrayList.newListWith(false, true, false)));
    BooleanIterable trueCollection = this.newWith(true, true, true, true);
    Assert.assertFalse(trueCollection.containsAll(BooleanArrayList.newListWith(true, false)));
    BooleanIterable falseCollection = this.newWith(false, false, false, false);
    Assert.assertFalse(falseCollection.containsAll(BooleanArrayList.newListWith(true, false)));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 18 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class AbstractBooleanIterableTestCase method testEquals.

@Test
public void testEquals() {
    BooleanIterable iterable1 = this.newWith(true, false, true, false);
    BooleanIterable iterable2 = this.newWith(true, false, true, false);
    BooleanIterable iterable3 = this.newWith(false, false, false, true);
    BooleanIterable iterable4 = this.newWith(true, true, true);
    BooleanIterable iterable5 = this.newWith(true, true, false, false, false);
    BooleanIterable iterable6 = this.newWith(true);
    Verify.assertEqualsAndHashCode(iterable1, iterable2);
    Verify.assertEqualsAndHashCode(this.newWith(), this.newWith());
    Verify.assertPostSerializedEqualsAndHashCode(iterable6);
    Verify.assertPostSerializedEqualsAndHashCode(iterable1);
    Verify.assertPostSerializedEqualsAndHashCode(iterable5);
    Assert.assertNotEquals(iterable1, iterable3);
    Assert.assertNotEquals(iterable1, iterable4);
    Assert.assertNotEquals(this.newWith(), this.newWith(true));
    Assert.assertNotEquals(iterable6, this.newWith(true, false));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Test(org.junit.Test)

Example 19 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class AbstractBooleanIterableTestCase method reject.

@Test
public void reject() {
    BooleanIterable iterable = this.classUnderTest();
    int size = iterable.size();
    int halfSize = size / 2;
    Verify.assertSize(halfSize, iterable.reject(BooleanPredicates.isTrue()));
    Verify.assertSize((size & 1) == 1 ? halfSize + 1 : halfSize, iterable.reject(BooleanPredicates.isFalse()));
    BooleanIterable iterable1 = this.newWith(false, true, false, false, true, true, true);
    Assert.assertEquals(this.newMutableCollectionWith(false, false, false), iterable1.reject(BooleanPredicates.isTrue()));
    Assert.assertEquals(this.newMutableCollectionWith(true, true, true, true), iterable1.reject(BooleanPredicates.isFalse()));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Test(org.junit.Test)

Example 20 with BooleanIterable

use of org.eclipse.collections.api.BooleanIterable in project eclipse-collections by eclipse.

the class AbstractBooleanIterableTestCase method testToString.

@Test
public void testToString() {
    Assert.assertEquals("[]", this.newWith().toString());
    Assert.assertEquals("[true]", this.newWith(true).toString());
    BooleanIterable iterable = this.newWith(true, false);
    Assert.assertTrue("[true, false]".equals(iterable.toString()) || "[false, true]".equals(iterable.toString()));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Test(org.junit.Test)

Aggregations

BooleanIterable (org.eclipse.collections.api.BooleanIterable)54 Test (org.junit.Test)47 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)27 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)11 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)8 MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)4 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)4 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)2 ReverseBooleanIterable (org.eclipse.collections.impl.lazy.primitive.ReverseBooleanIterable)2 NoSuchElementException (java.util.NoSuchElementException)1 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)1 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)1 BooleanPredicates (org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates)1 FastList (org.eclipse.collections.impl.list.mutable.FastList)1 MutableInteger (org.eclipse.collections.impl.math.MutableInteger)1 AbstractBooleanIterable (org.eclipse.collections.impl.primitive.AbstractBooleanIterable)1 SynchronizedBooleanIterable (org.eclipse.collections.impl.primitive.SynchronizedBooleanIterable)1 BooleanHashSet (org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1