Search in sources :

Example 36 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method retainAll.

@Test
public void retainAll() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.retainAll(this.newMutableCollectionWith(true, false)));
    Assert.assertTrue(collection.retainAll(this.newMutableCollectionWith(true)));
    Assert.assertEquals(this.newMutableCollectionWith(true, true), collection);
    Assert.assertTrue(collection.retainAll(this.newMutableCollectionWith(false, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection);
    MutableBooleanCollection list = this.classUnderTest();
    Assert.assertFalse(list.retainAll(BooleanArrayList.newListWith(false, false, true)));
    MutableBooleanCollection booleanArrayList = this.newWith(false, false);
    Assert.assertFalse(booleanArrayList.retainAll(new BooleanArrayList(false)));
    Assert.assertEquals(this.newMutableCollectionWith(false, false), booleanArrayList);
    Assert.assertTrue(booleanArrayList.retainAll(new BooleanArrayList(true)));
    Assert.assertEquals(this.newMutableCollectionWith(), booleanArrayList);
    Assert.assertTrue(list.retainAll(new BooleanArrayList(false)));
    Assert.assertEquals(this.newMutableCollectionWith(false), list);
    Assert.assertTrue(list.retainAll(new BooleanArrayList()));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    Assert.assertFalse(list.retainAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    MutableBooleanCollection list1 = this.newWith(true, false, true, true);
    Assert.assertFalse(list1.retainAll(BooleanArrayList.newListWith(false, false, true)));
    Assert.assertTrue(list1.retainAll(BooleanArrayList.newListWith(false, false)));
    Verify.assertSize(1, list1);
    Assert.assertFalse(list1.contains(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), list1);
    Assert.assertTrue(list1.retainAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertEquals(this.newMutableCollectionWith(), list1);
    MutableBooleanCollection list2 = this.newWith(true, false, true, false, true);
    Assert.assertTrue(list2.retainAll(new BooleanHashBag()));
    Assert.assertEquals(this.newMutableCollectionWith(), list2);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 37 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method retainAll_iterable.

@Test
public void retainAll_iterable() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.retainAll(true, false));
    Assert.assertTrue(collection.retainAll(true));
    Assert.assertEquals(this.newMutableCollectionWith(true, true), collection);
    Assert.assertTrue(collection.retainAll(false, false));
    Assert.assertEquals(this.newMutableCollectionWith(), collection);
    MutableBooleanCollection list = this.classUnderTest();
    Assert.assertFalse(list.retainAll(false, false, true));
    MutableBooleanCollection booleanArrayList = this.newWith(false, false);
    Assert.assertFalse(booleanArrayList.retainAll(false));
    Assert.assertEquals(this.newMutableCollectionWith(false, false), booleanArrayList);
    Assert.assertTrue(booleanArrayList.retainAll(true));
    Assert.assertEquals(this.newMutableCollectionWith(), booleanArrayList);
    Assert.assertTrue(list.retainAll(false));
    Assert.assertEquals(this.newMutableCollectionWith(false), list);
    Assert.assertTrue(list.retainAll());
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    Assert.assertFalse(list.retainAll(true, false));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    MutableBooleanCollection list1 = this.newWith(true, false, true, true);
    Assert.assertFalse(list1.retainAll(false, false, true));
    Assert.assertTrue(list1.retainAll(false, false));
    Verify.assertSize(1, list1);
    Assert.assertFalse(list1.contains(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), list1);
    Assert.assertTrue(list1.retainAll(true, true));
    Assert.assertEquals(this.newMutableCollectionWith(), list1);
    MutableBooleanCollection list2 = this.newWith(true, false, true, false, true);
    Assert.assertTrue(list2.retainAll());
    Assert.assertEquals(this.newMutableCollectionWith(), list2);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 38 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method iterator_throws_on_consecutive_invocation_of_remove.

@Test
public void iterator_throws_on_consecutive_invocation_of_remove() {
    MutableBooleanCollection booleanIterable = this.newWith(true, false);
    MutableBooleanIterator iterator = booleanIterable.booleanIterator();
    iterator.next();
    iterator.remove();
    Verify.assertThrows(IllegalStateException.class, iterator::remove);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Example 39 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method withoutAll.

@Test
public void withoutAll() {
    MutableBooleanCollection mainCollection = this.newWith(true, false, true, false, true);
    Assert.assertEquals(this.newMutableCollectionWith(true, true, true), mainCollection.withoutAll(this.newMutableCollectionWith(false, false)));
    MutableBooleanCollection collection = this.newWith(true, false, true, false, true);
    Assert.assertEquals(this.newMutableCollectionWith(true, true, true), collection.withoutAll(BooleanHashBag.newBagWith(false)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection.withoutAll(BooleanHashBag.newBagWith(true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection.withoutAll(BooleanHashBag.newBagWith(true, false)));
    MutableBooleanCollection trueCollection = this.newWith(true, true, true);
    Assert.assertEquals(this.newMutableCollectionWith(true, true, true), trueCollection.withoutAll(BooleanArrayList.newListWith(false)));
    MutableBooleanCollection mutableBooleanCollection = trueCollection.withoutAll(BooleanArrayList.newListWith(true));
    Assert.assertEquals(this.newMutableCollectionWith(), mutableBooleanCollection);
    Assert.assertSame(trueCollection, mutableBooleanCollection);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 40 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method with.

@Test
public void with() {
    MutableBooleanCollection emptyCollection = this.newWith();
    MutableBooleanCollection collection = emptyCollection.with(true);
    MutableBooleanCollection collection0 = this.newWith().with(true).with(false);
    MutableBooleanCollection collection1 = this.newWith().with(true).with(false).with(true);
    MutableBooleanCollection collection2 = this.newWith().with(true).with(false).with(true).with(false);
    MutableBooleanCollection collection3 = this.newWith().with(true).with(false).with(true).with(false).with(true);
    Assert.assertSame(emptyCollection, collection);
    Assert.assertEquals(this.newMutableCollectionWith(true), collection);
    Assert.assertEquals(this.newMutableCollectionWith(true, false), collection0);
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true), 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)

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