Search in sources :

Example 6 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class AbstractMutableBooleanCollectionTestCase method removeAll.

@Test
public void removeAll() {
    Assert.assertFalse(this.newWith().removeAll(true));
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.removeAll());
    Assert.assertTrue(collection.removeAll(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), collection);
    Assert.assertFalse(collection.removeAll(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), collection);
    Assert.assertTrue(collection.removeAll(false, true));
    Assert.assertEquals(this.newMutableCollectionWith(), collection);
    MutableBooleanCollection booleanArrayCollection = this.newWith(false, false);
    Assert.assertFalse(booleanArrayCollection.removeAll(true));
    Assert.assertEquals(this.newMutableCollectionWith(false, false), booleanArrayCollection);
    Assert.assertTrue(booleanArrayCollection.removeAll(false));
    Assert.assertEquals(this.newMutableCollectionWith(), booleanArrayCollection);
    MutableBooleanCollection collection1 = this.classUnderTest();
    Assert.assertFalse(collection1.removeAll());
    Assert.assertTrue(collection1.removeAll(true, false));
    Assert.assertEquals(this.newMutableCollectionWith(), collection1);
    MutableBooleanCollection trueFalseList = this.newWith(true, false);
    Assert.assertTrue(trueFalseList.removeAll(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), trueFalseList);
    MutableBooleanCollection collection2 = this.newWith(true, false, true, false, true);
    Assert.assertFalse(collection2.removeAll());
    Assert.assertTrue(collection2.removeAll(true, true));
    Assert.assertEquals(this.newMutableCollectionWith(false, false), collection2);
    MutableBooleanCollection collection3 = this.newWith(true, false, true, false, true);
    Assert.assertFalse(collection3.removeAll());
    Assert.assertTrue(collection3.removeAll(true, false));
    Assert.assertEquals(this.newMutableCollectionWith(), collection3);
    MutableBooleanCollection collection4 = this.newWith(true, false, true, false, true);
    Assert.assertFalse(collection4.removeAll());
    Assert.assertTrue(collection4.removeAll(false, false));
    Assert.assertEquals(this.newMutableCollectionWith(true, true, true), collection4);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 7 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class AbstractMutableBooleanCollectionTestCase method add.

@Test
public void add() {
    MutableBooleanCollection emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.add(true));
    Assert.assertEquals(this.newMutableCollectionWith(true), emptyCollection);
    Assert.assertTrue(emptyCollection.add(false));
    Assert.assertEquals(this.newMutableCollectionWith(true, false), emptyCollection);
    Assert.assertTrue(emptyCollection.add(true));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true), emptyCollection);
    Assert.assertTrue(emptyCollection.add(false));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false), emptyCollection);
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertTrue(collection.add(false));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false), collection);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 8 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class AbstractLazyIterableTestCase method collectBooleanWithTarget.

@Test
public void collectBooleanWithTarget() {
    MutableBooleanCollection target = new BooleanArrayList();
    MutableBooleanCollection result = this.lazyIterable.collectBoolean(PrimitiveFunctions.integerIsPositive(), target);
    Assert.assertEquals(BooleanArrayList.newListWith(true, true, true, true, true, true, true), result.toList());
    Assert.assertSame("Target list sent as parameter not returned", target, result);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 9 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectBooleanWithTarget.

@Test
public void collectBooleanWithTarget() {
    MutableBooleanCollection target = new BooleanArrayList();
    BooleanIterable result = this.newWith(1, 0).collectBoolean(PrimitiveFunctions.integerIsPositive(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(BooleanBags.mutable.of(true, false), result.toBag());
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanIterable(org.eclipse.collections.api.BooleanIterable) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 10 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class IterateTest method collectBooleanWithTarget.

@Test
public void collectBooleanWithTarget() {
    this.iterables.each(each -> {
        MutableBooleanCollection expected = new BooleanArrayList();
        MutableBooleanCollection actual = Iterate.collectBoolean(each, PrimitiveFunctions.integerIsPositive(), expected);
        Assert.assertTrue(expected.containsAll(true, true, true, true, true));
        Assert.assertSame("Target list sent as parameter not returned", expected, actual);
    });
    Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectBoolean(null, PrimitiveFunctions.integerIsPositive(), new BooleanArrayList()));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Aggregations

MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)45 Test (org.junit.Test)43 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)11 MutableByteCollection (org.eclipse.collections.api.collection.primitive.MutableByteCollection)4 MutableCharCollection (org.eclipse.collections.api.collection.primitive.MutableCharCollection)4 MutableDoubleCollection (org.eclipse.collections.api.collection.primitive.MutableDoubleCollection)4 MutableFloatCollection (org.eclipse.collections.api.collection.primitive.MutableFloatCollection)4 MutableIntCollection (org.eclipse.collections.api.collection.primitive.MutableIntCollection)4 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)4 MutableShortCollection (org.eclipse.collections.api.collection.primitive.MutableShortCollection)4 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)4 Optional (java.util.Optional)3 RichIterable (org.eclipse.collections.api.RichIterable)3 MutableCollection (org.eclipse.collections.api.collection.MutableCollection)3 MutableList (org.eclipse.collections.api.list.MutableList)3 Pair (org.eclipse.collections.api.tuple.Pair)3 Predicates2 (org.eclipse.collections.impl.block.factory.Predicates2)3 Lists (org.eclipse.collections.impl.factory.Lists)3 List (java.util.List)2 Map (java.util.Map)2