Search in sources :

Example 6 with ImmutableBooleanList

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

the class BooleanListsTest method newListWithList.

@Test
public void newListWithList() {
    ImmutableBooleanList list = BooleanLists.immutable.of();
    BooleanArrayList booleanArrayList = BooleanArrayList.newListWith(true);
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.toImmutable());
    Assert.assertEquals(list = list.newWith(false), booleanArrayList.with(false).toImmutable());
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.with(true).toImmutable());
    Assert.assertEquals(list = list.newWith(false), booleanArrayList.with(false).toImmutable());
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.with(true).toImmutable());
    Assert.assertEquals(list = list.newWith(false), booleanArrayList.with(false).toImmutable());
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.with(true).toImmutable());
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.with(true).toImmutable());
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.with(true).toImmutable());
    Assert.assertEquals(list = list.newWith(false), booleanArrayList.with(false).toImmutable());
    Assert.assertEquals(list = list.newWith(true), booleanArrayList.with(true).toImmutable());
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 7 with ImmutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method testEquals.

@Override
@Test
public void testEquals() {
    super.testEquals();
    ImmutableBooleanList list1 = this.newWith(true, false, true, true);
    ImmutableBooleanList list2 = this.newWith(true, true, false, true);
    Assert.assertNotEquals(list1, list2);
}
Also used : ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 8 with ImmutableBooleanList

use of org.eclipse.collections.api.list.primitive.ImmutableBooleanList 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 9 with ImmutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method newWithOn64ElementCollection.

@Test
public void newWithOn64ElementCollection() {
    BooleanArrayList sixtyFourElementCollection = new BooleanArrayList();
    for (int i = 0; i < 64; i++) {
        sixtyFourElementCollection.add(true);
    }
    ImmutableBooleanList immutableBooleanList = sixtyFourElementCollection.toImmutable();
    Assert.assertEquals(sixtyFourElementCollection, immutableBooleanList);
    ImmutableBooleanList newImmutableBooleanList = immutableBooleanList.newWith(false);
    Assert.assertFalse(newImmutableBooleanList.get(64));
    ImmutableBooleanList newImmutableBooleanList1 = immutableBooleanList.newWith(true);
    Assert.assertTrue(newImmutableBooleanList1.get(64));
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 10 with ImmutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method toReversed.

@Test
public void toReversed() {
    Assert.assertEquals(BooleanArrayList.newListWith(true, true, false, false), this.newWith(false, false, true, true).toReversed());
    ImmutableBooleanList originalList = this.newWith(true, true, false, false);
    Assert.assertNotSame(originalList, originalList.toReversed());
}
Also used : ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Aggregations

ImmutableBooleanList (org.eclipse.collections.api.list.primitive.ImmutableBooleanList)13 Test (org.junit.Test)13 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 MutableInteger (org.eclipse.collections.impl.math.MutableInteger)1