Search in sources :

Example 6 with MutableBooleanBag

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

the class AbstractMutableBooleanBagTestCase method noneSatisfy.

@Override
@Test
public void noneSatisfy() {
    super.noneSatisfy();
    MutableBooleanBag bag = this.newWith(false, true, false);
    Assert.assertFalse(bag.noneSatisfy(value -> value));
}
Also used : BooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction) 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) MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) Lists(org.eclipse.collections.impl.factory.Lists) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) AbstractMutableBooleanCollectionTestCase(org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableBooleanCollectionTestCase) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) Assert(org.junit.Assert) MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) Test(org.junit.Test)

Example 7 with MutableBooleanBag

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

the class AbstractMutableBooleanBagTestCase method anySatisfy.

@Override
@Test
public void anySatisfy() {
    super.anySatisfy();
    long[] count = { 0 };
    MutableBooleanBag bag = this.newWith(false, true, false);
    Assert.assertTrue(bag.anySatisfy(value -> {
        count[0]++;
        return value;
    }));
    Assert.assertEquals(2L, count[0]);
}
Also used : BooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction) 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) MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) Lists(org.eclipse.collections.impl.factory.Lists) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) AbstractMutableBooleanCollectionTestCase(org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableBooleanCollectionTestCase) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) Assert(org.junit.Assert) MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) Test(org.junit.Test)

Example 8 with MutableBooleanBag

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

the class AbstractMutableBooleanBagTestCase method addOccurrences.

@Test
public void addOccurrences() {
    MutableBooleanBag bag = this.newWith();
    bag.addOccurrences(false, 3);
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false), bag);
    bag.addOccurrences(false, 2);
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false, false, false), bag);
    bag.addOccurrences(false, 0);
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false, false, false), bag);
    bag.addOccurrences(true, 0);
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false, false, false), bag);
    bag.addOccurrences(true, 1);
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false, false, false, true), bag);
}
Also used : MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) Test(org.junit.Test)

Example 9 with MutableBooleanBag

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

the class AbstractMutableBooleanBagTestCase method removeOccurrences.

@Test
public void removeOccurrences() {
    MutableBooleanBag bag1 = this.newWith();
    Assert.assertFalse(bag1.removeOccurrences(true, 5));
    bag1.addOccurrences(true, 5);
    Assert.assertTrue(bag1.removeOccurrences(true, 2));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, true, true), bag1);
    Assert.assertFalse(bag1.removeOccurrences(true, 0));
    Assert.assertEquals(BooleanHashBag.newBagWith(true, true, true), bag1);
    Assert.assertTrue(bag1.removeOccurrences(true, 5));
    Assert.assertEquals(new BooleanHashBag(), bag1);
    Assert.assertFalse(bag1.removeOccurrences(true, 5));
    Assert.assertEquals(new BooleanHashBag(), bag1);
    MutableBooleanBag bag2 = this.newWith();
    Assert.assertFalse(bag2.removeOccurrences(false, 5));
    bag2.addOccurrences(false, 5);
    Assert.assertTrue(bag2.removeOccurrences(false, 2));
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false), bag2);
    Assert.assertFalse(bag2.removeOccurrences(false, 0));
    Assert.assertEquals(BooleanHashBag.newBagWith(false, false, false), bag2);
    Assert.assertTrue(bag2.removeOccurrences(false, 5));
    Assert.assertEquals(new BooleanHashBag(), bag2);
    Assert.assertFalse(bag2.removeOccurrences(false, 5));
    Assert.assertEquals(new BooleanHashBag(), bag2);
}
Also used : MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) Test(org.junit.Test)

Example 10 with MutableBooleanBag

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

the class AbstractMutableBooleanBagTestCase method appendString.

@Override
@Test
public void appendString() {
    super.appendString();
    StringBuilder appendable1 = new StringBuilder();
    this.newWith(true, true, true).appendString(appendable1);
    Assert.assertEquals("true, true, true", appendable1.toString());
    StringBuilder appendable2 = new StringBuilder();
    MutableBooleanBag bag1 = this.newWith(false, false, true);
    bag1.appendString(appendable2);
    Assert.assertTrue(appendable2.toString(), "false, false, true".equals(appendable2.toString()) || "true, false, false".equals(appendable2.toString()) || "false, true, false".equals(appendable2.toString()));
}
Also used : MutableBooleanBag(org.eclipse.collections.api.bag.primitive.MutableBooleanBag) Test(org.junit.Test)

Aggregations

MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)19 Test (org.junit.Test)9 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)5 BooleanIterable (org.eclipse.collections.api.BooleanIterable)4 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)4 MutableBag (org.eclipse.collections.api.bag.MutableBag)4 ImmutableBooleanBag (org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag)4 BooleanToObjectFunction (org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction)4 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)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 AbstractMutableBooleanCollectionTestCase (org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableBooleanCollectionTestCase)4 Lists (org.eclipse.collections.impl.factory.Lists)4 Verify (org.eclipse.collections.impl.test.Verify)4 PrimitiveTuples (org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples)4 Assert (org.junit.Assert)4 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)3 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)2 AbstractBooleanIterable (org.eclipse.collections.impl.primitive.AbstractBooleanIterable)1