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));
}
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));
}
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));
}
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 }));
}
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());
}
Aggregations