Search in sources :

Example 1 with ImmutableBooleanBag

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

the class BooleanBagsTest method newBagWith.

@Test
public void newBagWith() {
    ImmutableBooleanBag bag = BooleanBags.immutable.of();
    Assert.assertEquals(bag, BooleanBags.immutable.of(bag.toArray()));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true));
    Assert.assertEquals(bag = bag.newWith(false), BooleanBags.immutable.of(true, false));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true, false, true));
    Assert.assertEquals(bag = bag.newWith(false), BooleanBags.immutable.of(true, false, true, false));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true, false, true, false, true));
    Assert.assertEquals(bag = bag.newWith(false), BooleanBags.immutable.of(true, false, true, false, true, false));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true, false, true, false, true, false, true));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true, false, true, false, true, false, true, true));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true, false, true, false, true, false, true, true, true));
    Assert.assertEquals(bag = bag.newWith(false), BooleanBags.immutable.of(true, false, true, false, true, false, true, true, true, false));
    Assert.assertEquals(bag = bag.newWith(true), BooleanBags.immutable.of(true, false, true, false, true, false, true, true, true, false, true));
    Assert.assertEquals(bag = bag.newWith(false), BooleanBags.immutable.of(true, false, true, false, true, false, true, true, true, false, true, false));
}
Also used : ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) Test(org.junit.Test)

Example 2 with ImmutableBooleanBag

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

the class ImmutableBagTestCase method collectBoolean.

@Override
@Test
public void collectBoolean() {
    super.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 3 with ImmutableBooleanBag

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

the class AbstractImmutableBooleanBagTestCase method collect.

@Override
@Test
public void collect() {
    super.collect();
    ImmutableBooleanBag bag = this.newWith(true, false, false, true, true, true);
    BooleanToObjectFunction<String> stringValueOf = parameter -> parameter ? "true" : "false";
    Assert.assertEquals(HashBag.newBagWith("true", "false", "false", "true", "true", "true"), bag.collect(stringValueOf));
    ImmutableBooleanBag bag1 = this.newWith(false, false);
    Assert.assertEquals(HashBag.newBagWith("false", "false"), bag1.collect(stringValueOf));
    ImmutableBooleanBag bag2 = this.newWith(true, true);
    Assert.assertEquals(HashBag.newBagWith("true", "true"), bag2.collect(stringValueOf));
}
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 4 with ImmutableBooleanBag

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

the class BooleanBagsTest method newBagWithArray.

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

Example 5 with ImmutableBooleanBag

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

the class BooleanBagsTest method newBagWithBag.

@Test
public void newBagWithBag() {
    ImmutableBooleanBag bag = BooleanBags.immutable.of();
    BooleanHashBag booleanHashBag = BooleanHashBag.newBagWith(true);
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.toImmutable());
    Assert.assertEquals(bag = bag.newWith(false), booleanHashBag.with(false).toImmutable());
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.with(true).toImmutable());
    Assert.assertEquals(bag = bag.newWith(false), booleanHashBag.with(false).toImmutable());
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.with(true).toImmutable());
    Assert.assertEquals(bag = bag.newWith(false), booleanHashBag.with(false).toImmutable());
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.with(true).toImmutable());
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.with(true).toImmutable());
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.with(true).toImmutable());
    Assert.assertEquals(bag = bag.newWith(false), booleanHashBag.with(false).toImmutable());
    Assert.assertEquals(bag = bag.newWith(true), booleanHashBag.with(true).toImmutable());
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) 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