Search in sources :

Example 21 with MutableBooleanList

use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanListTestCase method newWithAll.

@Override
@Test
public void newWithAll() {
    ImmutableBooleanCollection booleanCollection = this.classUnderTest();
    MutableBooleanList list = booleanCollection.toList();
    ImmutableBooleanCollection collection = booleanCollection.newWithAll(this.newMutableCollectionWith(true));
    ImmutableBooleanCollection collection0 = booleanCollection.newWithAll(this.newMutableCollectionWith(true, false));
    ImmutableBooleanCollection collection1 = booleanCollection.newWithAll(this.newMutableCollectionWith(true, false, true));
    ImmutableBooleanCollection collection2 = booleanCollection.newWithAll(this.newMutableCollectionWith(true, false, true, false));
    ImmutableBooleanCollection collection3 = booleanCollection.newWithAll(this.newMutableCollectionWith(true, false, true, false, true));
    ImmutableBooleanCollection collection4 = collection3.newWithAll(this.newMutableCollectionWith(true, false, true, false, true));
    Assert.assertEquals(list, booleanCollection);
    Assert.assertEquals(list.with(true), collection);
    Assert.assertEquals(list.with(false), collection0);
    Assert.assertEquals(list.with(true), collection1);
    Assert.assertEquals(list.with(false), collection2);
    Assert.assertEquals(list.with(true), collection3);
    list.addAll(true, false, true, false, true);
    Assert.assertEquals(list, collection4);
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) Test(org.junit.Test)

Example 22 with MutableBooleanList

use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanListTestCase method newWithoutAll.

@Override
@Test
public void newWithoutAll() {
    ImmutableBooleanCollection immutableBooleanCollection = this.classUnderTest();
    MutableBooleanCollection mutableTrueCollection = this.getTrueCollection(immutableBooleanCollection);
    ImmutableBooleanCollection trueCollection = mutableTrueCollection.toImmutable();
    Assert.assertEquals(this.newMutableCollectionWith(), trueCollection.newWithoutAll(this.newMutableCollectionWith(true, false)));
    Assert.assertEquals(mutableTrueCollection, trueCollection);
    MutableBooleanList list = immutableBooleanCollection.toList();
    list.removeAll(true);
    Assert.assertEquals(list, immutableBooleanCollection.newWithoutAll(this.newMutableCollectionWith(true)));
    Assert.assertEquals(this.newMutableCollectionWith(), immutableBooleanCollection.newWithoutAll(this.newMutableCollectionWith(true, false)));
    ImmutableBooleanCollection collection = this.newWith(true, false, true, false, true);
    Assert.assertEquals(this.newMutableCollectionWith(false, false), collection.newWithoutAll(this.newMutableCollectionWith(true, true)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection.newWithoutAll(this.newMutableCollectionWith(true, false)));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) Test(org.junit.Test)

Example 23 with MutableBooleanList

use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanListTestCase method lastIndexOf.

@Test
public void lastIndexOf() {
    ImmutableBooleanList list = this.classUnderTest();
    int size = list.size();
    Assert.assertEquals((size & 1) == 0 ? size - 2 : size - 1, list.lastIndexOf(true));
    Assert.assertEquals((size & 1) == 0 ? size - 1 : size - 2, list.lastIndexOf(false));
    MutableBooleanList mutableList = this.newMutableCollectionWith();
    for (int i = 0; i < list.size(); i++) {
        mutableList.add(false);
    }
    Assert.assertEquals(-1L, mutableList.toImmutable().lastIndexOf(true));
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 24 with MutableBooleanList

use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanListTestCase method indexOf.

@Test
public void indexOf() {
    ImmutableBooleanList list = this.classUnderTest();
    Assert.assertEquals(0L, list.indexOf(true));
    Assert.assertEquals(list.size() > 2 ? 1L : -1L, list.indexOf(false));
    MutableBooleanList mutableList = this.newMutableCollectionWith();
    for (int i = 0; i < list.size(); i++) {
        mutableList.add(false);
    }
    Assert.assertEquals(-1L, mutableList.toImmutable().indexOf(true));
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 25 with MutableBooleanList

use of org.eclipse.collections.api.list.primitive.MutableBooleanList in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanBagTestCase method toList.

@Override
@Test
public void toList() {
    super.toList();
    MutableBooleanList list = this.newWith(false, false, true).toList();
    Assert.assertTrue(list.equals(BooleanArrayList.newListWith(false, false, true)) || list.equals(BooleanArrayList.newListWith(true, false, false)) || list.equals(BooleanArrayList.newListWith(false, true, false)));
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Aggregations

MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)44 Test (org.junit.Test)38 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)6 ImmutableBooleanCollection (org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection)4 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)3 BooleanList (org.eclipse.collections.api.list.primitive.BooleanList)3 ImmutableBooleanList (org.eclipse.collections.api.list.primitive.ImmutableBooleanList)3 Verify (org.eclipse.collections.impl.test.Verify)3 Assert (org.junit.Assert)3 ArrayList (java.util.ArrayList)2 BooleanIterable (org.eclipse.collections.api.BooleanIterable)2 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)2 BooleanLists (org.eclipse.collections.impl.factory.primitive.BooleanLists)2 ReverseBooleanIterable (org.eclipse.collections.impl.lazy.primitive.ReverseBooleanIterable)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)2 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)2 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2