Search in sources :

Example 11 with MutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method testNewWith.

@Override
@Test
public void testNewWith() {
    ImmutableBooleanCollection booleanCollection = this.classUnderTest();
    MutableBooleanList list = booleanCollection.toList();
    ImmutableBooleanCollection collection = booleanCollection.newWith(true);
    ImmutableBooleanCollection collection0 = booleanCollection.newWith(true).newWith(false);
    ImmutableBooleanCollection collection1 = booleanCollection.newWith(true).newWith(false).newWith(true);
    ImmutableBooleanCollection collection2 = booleanCollection.newWith(true).newWith(false).newWith(true).newWith(false);
    ImmutableBooleanCollection collection3 = booleanCollection.newWith(true).newWith(false).newWith(true).newWith(false).newWith(true);
    ImmutableBooleanCollection collection4 = collection3.newWith(true).newWith(false).newWith(true).newWith(false).newWith(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 12 with MutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method toList.

@Override
@Test
public void toList() {
    super.toList();
    MutableBooleanList list = this.classUnderTest().toList();
    Verify.assertEqualsAndHashCode(this.classUnderTest(), list);
    Assert.assertNotSame(this.classUnderTest(), list);
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Example 13 with MutableBooleanList

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

the class AbstractBooleanListTestCase method removeAtIndex.

@Test
public void removeAtIndex() {
    MutableBooleanList list = this.classUnderTest();
    list.removeAtIndex(1);
    Assert.assertEquals(BooleanArrayList.newListWith(true, true), list);
    list.removeAtIndex(1);
    Assert.assertEquals(BooleanArrayList.newListWith(true), list);
    list.removeAtIndex(0);
    Assert.assertEquals(BooleanArrayList.newListWith(), list);
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Example 14 with MutableBooleanList

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

the class AbstractBooleanListTestCase method removeIf.

@Test
public void removeIf() {
    Assert.assertFalse(this.newWith(true, true).removeIf(b -> !b));
    MutableBooleanList list = this.classUnderTest();
    Assert.assertTrue(list.removeIf(b -> b));
    Assert.assertEquals(BooleanArrayList.newListWith(false), list);
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) AbstractMutableBooleanCollectionTestCase(org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableBooleanCollectionTestCase) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) Assert(org.junit.Assert) MutableList(org.eclipse.collections.api.list.MutableList) FastList(org.eclipse.collections.impl.list.mutable.FastList) MutableInteger(org.eclipse.collections.impl.math.MutableInteger) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Example 15 with MutableBooleanList

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

the class AbstractBooleanListTestCase method lastIndexOf.

@Test
public void lastIndexOf() {
    MutableBooleanList list = this.newWith(true, false, true);
    Assert.assertEquals(2L, list.lastIndexOf(true));
    Assert.assertEquals(1L, list.lastIndexOf(false));
    Assert.assertEquals(-1L, this.newWith(false, false).lastIndexOf(true));
    MutableBooleanList emptyList = this.newWith();
    Assert.assertEquals(-1L, emptyList.lastIndexOf(true));
    Assert.assertEquals(-1L, emptyList.lastIndexOf(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