Search in sources :

Example 1 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class BooleanBagsTest method immutables.

@Test
public void immutables() {
    ImmutableBooleanBagFactory bagFactory = BooleanBags.immutable;
    Assert.assertEquals(new BooleanHashBag(), bagFactory.of());
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of());
    Assert.assertEquals(BooleanHashBag.newBagWith(true), bagFactory.of(true));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false), bagFactory.of(true, false));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true), bagFactory.of(true, false, true));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false), bagFactory.of(true, false, true, false));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true), bagFactory.of(true, false, true, false, true));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false, true));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true, false), bagFactory.of(true, false, true, false, true, false));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false, true, false));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true, false, true), bagFactory.of(true, false, true, false, true, false, true));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false, true, false, true));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true, false, true, true), bagFactory.of(true, false, true, false, true, false, true, true));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false, true, false, true, true));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true, false, true, true, true), bagFactory.of(true, false, true, false, true, false, true, true, true));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false, true, false, true, true, true));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true, false, true, false, true, true, true, false), bagFactory.of(true, false, true, false, true, false, true, true, true, false));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.of(true, false, true, false, true, false, true, true, true, false));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false, true), bagFactory.ofAll(BooleanHashBag.newBagWith(true, false, true)));
    Verify.assertInstanceOf(ImmutableBooleanBag.class, bagFactory.ofAll(BooleanHashBag.newBagWith(true, false, true)));
}
Also used : ImmutableBooleanBagFactory(org.eclipse.collections.api.factory.bag.primitive.ImmutableBooleanBagFactory) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 2 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class ImmutableEmptyBagTest method collectBooleanWithTarget.

@Override
@Test
public void collectBooleanWithTarget() {
    BooleanHashBag target = new BooleanHashBag();
    BooleanHashBag result = this.newBag().collectBoolean("4"::equals, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(0, result.sizeDistinct());
    Assert.assertEquals(0, result.occurrencesOf(true));
    Assert.assertEquals(0, result.occurrencesOf(false));
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 3 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class ImmutableSingletonBagTest method collectBooleanWithTarget.

@Override
@Test
public void collectBooleanWithTarget() {
    BooleanHashBag target = new BooleanHashBag();
    BooleanHashBag result = this.newBag().collectBoolean("4"::equals, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(1, result.sizeDistinct());
    Assert.assertEquals(0, result.occurrencesOf(true));
    Assert.assertEquals(1, result.occurrencesOf(false));
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 4 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanBagTestCase method booleanIterator.

@Override
@Test
public void booleanIterator() {
    BooleanHashBag bag = BooleanHashBag.newBagWith();
    BooleanIterator iterator = this.classUnderTest().booleanIterator();
    for (int i = 0; i < this.classUnderTest().size(); i++) {
        Assert.assertTrue(iterator.hasNext());
        bag.add(iterator.next());
    }
    Assert.assertEquals(bag, this.classUnderTest());
    Assert.assertFalse(iterator.hasNext());
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Example 5 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectBooleanWithBagTarget.

@Test
public void collectBooleanWithBagTarget() {
    BooleanHashBag target = new BooleanHashBag();
    BooleanHashBag result = this.newWith(1, 0).collectBoolean(PrimitiveFunctions.integerIsPositive(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(BooleanHashBag.newBagWith(true, false), result);
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Aggregations

BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)23 Test (org.junit.Test)21 NoSuchElementException (java.util.NoSuchElementException)8 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)8 Assert (org.junit.Assert)8 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)7 FastList (org.eclipse.collections.impl.list.mutable.FastList)7 Verify (org.eclipse.collections.impl.test.Verify)7 ImmutableObjectBooleanMap (org.eclipse.collections.api.map.primitive.ImmutableObjectBooleanMap)6 ObjectBooleanMap (org.eclipse.collections.api.map.primitive.ObjectBooleanMap)6 BooleanHashSet (org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)6 BooleanPredicates (org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates)4 UnifiedMap (org.eclipse.collections.impl.map.mutable.UnifiedMap)4 ObjectBooleanHashMap (org.eclipse.collections.impl.map.mutable.primitive.ObjectBooleanHashMap)3 Arrays (java.util.Arrays)2 MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)2 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Iterator (java.util.Iterator)1 List (java.util.List)1