Search in sources :

Example 1 with ImmutableBooleanList

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

the class BooleanListsTest method newListWithArray.

@SuppressWarnings("RedundantArrayCreation")
@Test
public void newListWithArray() {
    ImmutableBooleanList list = BooleanLists.immutable.of();
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true }));
    Assert.assertEquals(list = list.newWith(false), BooleanLists.immutable.of(new boolean[] { true, false }));
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true, false, true }));
    Assert.assertEquals(list = list.newWith(false), BooleanLists.immutable.of(new boolean[] { true, false, true, false }));
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true }));
    Assert.assertEquals(list = list.newWith(false), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true, false }));
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true, false, true }));
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true, false, true, true }));
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true, false, true, true, true }));
    Assert.assertEquals(list = list.newWith(false), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true, false, true, true, true, false }));
    Assert.assertEquals(list = list.newWith(true), BooleanLists.immutable.of(new boolean[] { true, false, true, false, true, false, true, true, true, false, true }));
}
Also used : ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 2 with ImmutableBooleanList

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

the class BooleanListsTest method newListWith.

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

Example 3 with ImmutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method get_throws_index_greater_than_size.

@Test(expected = IndexOutOfBoundsException.class)
public void get_throws_index_greater_than_size() {
    ImmutableBooleanList list = this.classUnderTest();
    list.get(list.size());
}
Also used : ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 4 with ImmutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method injectIntoWithIndex.

@Test
public void injectIntoWithIndex() {
    ImmutableBooleanList list = this.newWith(true, false, true);
    MutableInteger result = list.injectIntoWithIndex(new MutableInteger(0), (object, value, index) -> object.add((value ? 1 : 0) + index));
    Assert.assertEquals(new MutableInteger(5), result);
}
Also used : MutableInteger(org.eclipse.collections.impl.math.MutableInteger) ImmutableBooleanList(org.eclipse.collections.api.list.primitive.ImmutableBooleanList) Test(org.junit.Test)

Example 5 with ImmutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method toArray.

@Override
@Test
public void toArray() {
    super.toArray();
    ImmutableBooleanList list = this.classUnderTest();
    Assert.assertEquals(this.classUnderTest().size(), list.toArray().length);
    for (int i = 0; i < this.classUnderTest().size(); i++) {
        Assert.assertEquals((i & 1) == 0, list.toArray()[i]);
    }
}
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