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