Search in sources :

Example 6 with MutableBooleanList

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

the class BooleanHashBagTest method toList.

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

Example 7 with MutableBooleanList

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

the class BooleanCaseProcedureTest method noopCaseAndThenDefault.

@Test
public void noopCaseAndThenDefault() {
    MutableBooleanList result = BooleanLists.mutable.empty();
    BooleanList source = BooleanLists.mutable.with(true, false);
    BooleanCaseProcedure procedure = new BooleanCaseProcedure();
    source.each(procedure);
    Verify.assertEmpty(result);
    procedure.setDefault(result::add);
    source.each(procedure);
    Assert.assertEquals(result, source);
    Verify.assertContains("BooleanCaseProcedure", procedure.toString());
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Example 8 with MutableBooleanList

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

the class BooleanCaseProcedureTest method twoCasesWithDefault.

@Test
public void twoCasesWithDefault() {
    MutableBooleanList ifOneList = BooleanLists.mutable.empty();
    MutableBooleanList ifTwoList = BooleanLists.mutable.empty();
    MutableBooleanList defaultList = BooleanLists.mutable.empty();
    MutableBooleanList list = BooleanLists.mutable.with(true, true, false, false);
    BooleanCaseProcedure procedure = new BooleanCaseProcedure(defaultList::add).addCase(value -> value, ifOneList::add).addCase(value -> !value, ifTwoList::add);
    list.each(procedure);
    Assert.assertEquals(BooleanLists.mutable.with(true, true), ifOneList);
    Assert.assertEquals(BooleanLists.mutable.with(false, false), ifTwoList);
    Assert.assertEquals(BooleanLists.mutable.empty(), defaultList);
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) BooleanLists(org.eclipse.collections.impl.factory.primitive.BooleanLists) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) Assert(org.junit.Assert) BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Example 9 with MutableBooleanList

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

the class SynchronizedBooleanListTest method asSynchronized.

@Override
@Test
public void asSynchronized() {
    super.asSynchronized();
    SynchronizedBooleanList list = this.classUnderTest();
    MutableBooleanList listWithLockObject = new SynchronizedBooleanList(BooleanArrayList.newListWith(true, false, true), new Object()).asSynchronized();
    Assert.assertEquals(list, listWithLockObject);
    Assert.assertSame(listWithLockObject, listWithLockObject.asSynchronized());
    Assert.assertSame(list, list.asSynchronized());
    Assert.assertEquals(list, list.asSynchronized());
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Example 10 with MutableBooleanList

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

the class AbstractImmutableBooleanListTestCase method newWithout.

@Override
@Test
public void newWithout() {
    ImmutableBooleanCollection trueCollection = this.getTrueCollection(this.classUnderTest()).toImmutable();
    Assert.assertSame(trueCollection, trueCollection.newWithout(false));
    Assert.assertNotSame(trueCollection, trueCollection.newWithout(true));
    ImmutableBooleanCollection collection = this.classUnderTest();
    MutableBooleanList list = collection.toList();
    Assert.assertEquals(list.without(true), collection.newWithout(true));
    MutableBooleanList list1 = collection.toList();
    Assert.assertEquals(list1.without(false), collection.newWithout(false));
    Assert.assertEquals(this.classUnderTest(), collection);
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) 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