Search in sources :

Example 6 with ImmutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag in project eclipse-collections by eclipse.

the class ImmutableEmptyBagTest method collectBoolean.

@Override
@Test
public void collectBoolean() {
    ImmutableBooleanBag result = this.newBag().collectBoolean("4"::equals);
    Assert.assertEquals(0, result.sizeDistinct());
    Assert.assertEquals(0, result.occurrencesOf(true));
    Assert.assertEquals(0, result.occurrencesOf(false));
}
Also used : ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) Test(org.junit.Test)

Example 7 with ImmutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag in project eclipse-collections by eclipse.

the class ImmutableHashBagTest method collectBoolean.

@Override
@Test
public void collectBoolean() {
    ImmutableBooleanBag result = this.newBag().collectBoolean("4"::equals);
    Assert.assertEquals(2, result.sizeDistinct());
    Assert.assertEquals(4, result.occurrencesOf(true));
    Assert.assertEquals(6, result.occurrencesOf(false));
}
Also used : ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) Test(org.junit.Test)

Example 8 with ImmutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag in project eclipse-collections by eclipse.

the class ImmutableSingletonBagTest method collectBoolean.

@Override
@Test
public void collectBoolean() {
    ImmutableBooleanBag result = this.newBag().collectBoolean("4"::equals);
    Assert.assertEquals(1, result.sizeDistinct());
    Assert.assertEquals(0, result.occurrencesOf(true));
    Assert.assertEquals(1, result.occurrencesOf(false));
}
Also used : ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) Test(org.junit.Test)

Example 9 with ImmutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanBagTestCase method allSatisfy.

@Override
@Test
public void allSatisfy() {
    super.allSatisfy();
    int[] count = { 0 };
    ImmutableBooleanBag bag = this.newWith(false, true, false);
    Assert.assertFalse(bag.allSatisfy(value -> {
        count[0]++;
        return !value;
    }));
    Assert.assertEquals(2L, count[0]);
}
Also used : BooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction) AbstractImmutableBooleanCollectionTestCase(org.eclipse.collections.impl.collection.immutable.primitive.AbstractImmutableBooleanCollectionTestCase) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) MutableBag(org.eclipse.collections.api.bag.MutableBag) ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) BooleanBags(org.eclipse.collections.impl.factory.primitive.BooleanBags) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Assert(org.junit.Assert) MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) Test(org.junit.Test)

Example 10 with ImmutableBooleanBag

use of org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanBagTestCase method toImmutable.

@Test
public void toImmutable() {
    Assert.assertEquals(this.classUnderTest(), this.classUnderTest().toImmutable());
    ImmutableBooleanBag expected = this.classUnderTest();
    Assert.assertSame(expected, expected.toImmutable());
}
Also used : ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) Test(org.junit.Test)

Aggregations

ImmutableBooleanBag (org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag)13 Test (org.junit.Test)13 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)5 MutableBag (org.eclipse.collections.api.bag.MutableBag)4 MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)4 BooleanToObjectFunction (org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction)4 ImmutableBooleanCollection (org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection)4 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)4 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)4 HashBag (org.eclipse.collections.impl.bag.mutable.HashBag)4 AbstractImmutableBooleanCollectionTestCase (org.eclipse.collections.impl.collection.immutable.primitive.AbstractImmutableBooleanCollectionTestCase)4 BooleanBags (org.eclipse.collections.impl.factory.primitive.BooleanBags)4 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)4 Verify (org.eclipse.collections.impl.test.Verify)4 Assert (org.junit.Assert)4