Search in sources :

Example 41 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method addAllIterable.

@Test
public void addAllIterable() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.addAll(this.newMutableCollectionWith()));
    Assert.assertTrue(collection.addAll(this.newMutableCollectionWith(false, true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false, true, false), collection);
    Assert.assertTrue(collection.addAll(this.newMutableCollectionWith(true, false, true, false, true)));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false, true, false, true, false, true, false, true), collection);
    MutableBooleanCollection emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.addAll(BooleanArrayList.newListWith(true, false, true, false, true)));
    Assert.assertFalse(emptyCollection.addAll(new BooleanArrayList()));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false, true), emptyCollection);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 42 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method iterator_throws_on_invocation_of_remove_before_next.

@Test
public void iterator_throws_on_invocation_of_remove_before_next() {
    MutableBooleanCollection booleanIterable = this.newWith(true, false);
    MutableBooleanIterator iterator = booleanIterable.booleanIterator();
    Assert.assertTrue(iterator.hasNext());
    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 43 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method remove.

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

Example 44 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method without.

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

Example 45 with MutableBooleanCollection

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

the class AbstractMutableBooleanCollectionTestCase method asSynchronized.

@Test
public void asSynchronized() {
    MutableBooleanCollection collection = this.classUnderTest();
    Verify.assertInstanceOf(this.newWith(true, false, true).asSynchronized().getClass(), collection.asSynchronized());
    Assert.assertEquals(this.newWith(true, false, true).asSynchronized(), collection.asSynchronized());
    Assert.assertEquals(collection, collection.asSynchronized());
}
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