Search in sources :

Example 1 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method withAll.

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

Example 2 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method containsAllIterable.

@Override
@Test
public void containsAllIterable() {
    super.containsAllIterable();
    MutableBooleanCollection emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.containsAll(new BooleanArrayList()));
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(false)));
    emptyCollection.add(false);
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertTrue(emptyCollection.containsAll(BooleanArrayList.newListWith(false)));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 3 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method clear.

@Test
public void clear() {
    MutableBooleanCollection collection = this.classUnderTest();
    collection.clear();
    Verify.assertSize(0, collection);
    Verify.assertEmpty(collection);
    Assert.assertFalse(collection.contains(true));
    Assert.assertFalse(collection.contains(false));
    MutableBooleanCollection collection0 = this.newWith();
    MutableBooleanCollection collection1 = this.newWith(false);
    MutableBooleanCollection collection2 = this.newWith(true);
    MutableBooleanCollection collection3 = this.newWith(true, false);
    MutableBooleanCollection collection4 = this.newWith(true, false, true, false, true);
    collection0.clear();
    collection1.clear();
    collection2.clear();
    collection3.clear();
    collection4.clear();
    Verify.assertEmpty(collection0);
    Verify.assertEmpty(collection1);
    Verify.assertEmpty(collection2);
    Verify.assertEmpty(collection3);
    Verify.assertEmpty(collection4);
    Verify.assertSize(0, collection0);
    Verify.assertSize(0, collection1);
    Verify.assertSize(0, collection2);
    Verify.assertSize(0, collection3);
    Verify.assertSize(0, collection4);
    Assert.assertFalse(collection1.contains(false));
    Assert.assertFalse(collection2.contains(true));
    Assert.assertFalse(collection3.contains(true));
    Assert.assertFalse(collection3.contains(false));
    Assert.assertFalse(collection4.contains(false));
    Assert.assertEquals(this.newMutableCollectionWith(), collection0);
    Assert.assertEquals(this.newMutableCollectionWith(), collection1);
    Assert.assertEquals(this.newMutableCollectionWith(), collection2);
    Assert.assertEquals(this.newMutableCollectionWith(), collection3);
    Assert.assertEquals(this.newMutableCollectionWith(), collection4);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 4 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method booleanIterator_with_remove.

@Test
public void booleanIterator_with_remove() {
    MutableBooleanCollection booleanIterable = this.classUnderTest();
    MutableBooleanIterator iterator = booleanIterable.booleanIterator();
    int iterationCount = booleanIterable.size();
    int iterableSize = booleanIterable.size();
    for (int i = 0; i < iterationCount; i++) {
        Verify.assertSize(iterableSize--, booleanIterable);
        Assert.assertTrue(iterator.hasNext());
        iterator.next();
        iterator.remove();
        Verify.assertSize(iterableSize, booleanIterable);
    }
    Verify.assertEmpty(booleanIterable);
    Assert.assertFalse(iterator.hasNext());
    Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Example 5 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method removeAll_iterable.

@Test
public void removeAll_iterable() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.removeAll(this.newMutableCollectionWith()));
    Assert.assertTrue(collection.removeAll(this.newMutableCollectionWith(false)));
    Assert.assertEquals(this.newMutableCollectionWith(true, true), collection);
    Assert.assertTrue(collection.removeAll(this.newMutableCollectionWith(true, true)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection);
    MutableBooleanCollection list = this.classUnderTest();
    Assert.assertFalse(list.removeAll(new BooleanArrayList()));
    MutableBooleanCollection booleanArrayList = this.newWith(false, false);
    Assert.assertFalse(booleanArrayList.removeAll(new BooleanArrayList(true)));
    Assert.assertEquals(this.newMutableCollectionWith(false, false), booleanArrayList);
    Assert.assertTrue(booleanArrayList.removeAll(new BooleanArrayList(false)));
    Assert.assertEquals(this.newMutableCollectionWith(), booleanArrayList);
    Assert.assertTrue(list.removeAll(new BooleanArrayList(true)));
    Assert.assertEquals(this.newMutableCollectionWith(false), list);
    Assert.assertTrue(list.removeAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    Assert.assertFalse(list.removeAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    MutableBooleanCollection list1 = this.newWith(true, false, true, true);
    Assert.assertFalse(list1.removeAll(new BooleanArrayList()));
    Assert.assertTrue(list1.removeAll(BooleanArrayList.newListWith(true, true)));
    Verify.assertSize(1, list1);
    Assert.assertFalse(list1.contains(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), list1);
    Assert.assertTrue(list1.removeAll(BooleanArrayList.newListWith(false, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), list1);
    MutableBooleanCollection list2 = this.newWith(true, false, true, false, true);
    Assert.assertTrue(list2.removeAll(BooleanHashBag.newBagWith(true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), list2);
}
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