Search in sources :

Example 1 with BooleanIterable

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

the class AbstractMutableBooleanCollectionTestCase method chunk.

@Test
public void chunk() {
    BooleanIterable iterable1 = this.newWith(true);
    Verify.assertIterablesEqual(Lists.mutable.with(this.newMutableCollectionWith(true)).toSet(), iterable1.chunk(1).toSet());
    BooleanIterable iterable2 = this.newWith(false);
    Verify.assertIterablesEqual(Lists.mutable.with(this.newMutableCollectionWith(false)).toSet(), iterable2.chunk(1).toSet());
    BooleanIterable iterable3 = this.newWith(false, true);
    Verify.assertIterablesEqual(Lists.mutable.with(this.newMutableCollectionWith(false), this.newMutableCollectionWith(true)).toSet(), iterable3.chunk(1).toSet());
    Verify.assertIterablesEqual(Lists.mutable.with(this.newMutableCollectionWith(false, true)), iterable3.chunk(2));
    Verify.assertIterablesEqual(Lists.mutable.with(this.newMutableCollectionWith(false, true)), iterable3.chunk(3));
    Verify.assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().chunk(0));
    Verify.assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().chunk(-1));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) Test(org.junit.Test)

Example 2 with BooleanIterable

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

the class CollectBooleanIterableTest method containsAllArray.

@Test
public void containsAllArray() {
    BooleanIterable booleanIterable = Interval.oneTo(3).collectBoolean(PrimitiveFunctions.integerIsPositive());
    Assert.assertTrue(booleanIterable.containsAll(true));
    Assert.assertTrue(booleanIterable.containsAll(true, true));
    Assert.assertFalse(booleanIterable.containsAll(false));
    Assert.assertFalse(booleanIterable.containsAll(false, false));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Test(org.junit.Test)

Example 3 with BooleanIterable

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

the class ReverseBooleanIterableTest method detectIfNone.

@Test
public void detectIfNone() {
    BooleanIterable iterable = BooleanArrayList.newListWith(false, false).asReversed();
    Assert.assertFalse(iterable.detectIfNone(BooleanPredicates.equal(false), true));
    Assert.assertTrue(iterable.detectIfNone(BooleanPredicates.equal(true), true));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) Test(org.junit.Test)

Example 4 with BooleanIterable

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

the class ReverseBooleanIterableTest method toArray.

@Test
public void toArray() {
    BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
    Assert.assertTrue(iterable.toArray()[0]);
    Assert.assertFalse(iterable.toArray()[1]);
    Assert.assertFalse(iterable.toArray()[2]);
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) Test(org.junit.Test)

Example 5 with BooleanIterable

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

the class ReverseBooleanIterableTest method collect.

@Test
public void collect() {
    BooleanIterable iterable = BooleanArrayList.newListWith(false, false, true).asReversed();
    Verify.assertIterablesEqual(FastList.newListWith(false, true, true), iterable.collect(parameter -> !parameter));
}
Also used : BooleanIterable(org.eclipse.collections.api.BooleanIterable) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test) BooleanPredicates(org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates) Verify(org.eclipse.collections.impl.test.Verify) NoSuchElementException(java.util.NoSuchElementException) Assert(org.junit.Assert) FastList(org.eclipse.collections.impl.list.mutable.FastList) BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) BooleanIterable(org.eclipse.collections.api.BooleanIterable) 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