use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectBooleanOverOptimizeLimit.
@Test
public void collectBooleanOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableBooleanList actual = ArrayListIterate.collectBoolean(list, PrimitiveFunctions.integerIsPositive());
BooleanArrayList expected = new BooleanArrayList(list.size());
expected.add(false);
for (int i = 1; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add(true);
}
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class IterateTest method collectBooleanWithTarget.
@Test
public void collectBooleanWithTarget() {
this.iterables.each(each -> {
MutableBooleanCollection expected = new BooleanArrayList();
MutableBooleanCollection actual = Iterate.collectBoolean(each, PrimitiveFunctions.integerIsPositive(), expected);
Assert.assertTrue(expected.containsAll(true, true, true, true, true));
Assert.assertSame("Target list sent as parameter not returned", expected, actual);
});
Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectBoolean(null, PrimitiveFunctions.integerIsPositive(), new BooleanArrayList()));
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class BooleanArrayStackTest method testPushPopAndPeek.
@Test
public void testPushPopAndPeek() {
BooleanArrayStack stack = BooleanArrayStack.newStackFromTopToBottom();
stack.push(true);
Assert.assertTrue(stack.peek());
Assert.assertEquals(BooleanArrayStack.newStackFromTopToBottom(true), stack);
stack.push(false);
Assert.assertFalse(stack.peek());
Assert.assertEquals(BooleanArrayStack.newStackFromTopToBottom(false, true), stack);
stack.push(true);
Assert.assertTrue(stack.peek());
Assert.assertEquals(BooleanArrayStack.newStackFromTopToBottom(true, false, true), stack);
Assert.assertFalse(stack.peekAt(1));
Assert.assertTrue(stack.pop());
Assert.assertFalse(stack.peek());
Assert.assertFalse(stack.pop());
Assert.assertTrue(stack.peek());
Assert.assertTrue(stack.pop());
BooleanArrayStack stack2 = BooleanArrayStack.newStackFromTopToBottom(true, false, true, false, true);
stack2.pop(2);
Assert.assertEquals(BooleanArrayStack.newStackFromTopToBottom(true, false, true), stack2);
Assert.assertEquals(BooleanArrayList.newListWith(true, false), stack2.peek(2));
BooleanArrayStack stack8 = BooleanArrayStack.newStackFromTopToBottom(false, true, false, true);
Verify.assertEmpty(stack8.pop(0));
Assert.assertEquals(BooleanArrayStack.newStackFromTopToBottom(false, true, false, true), stack8);
Assert.assertEquals(new BooleanArrayList(), stack8.peek(0));
BooleanArrayStack stack9 = BooleanArrayStack.newStackFromTopToBottom();
Assert.assertEquals(new BooleanArrayList(), stack9.pop(0));
Assert.assertEquals(new BooleanArrayList(), stack9.peek(0));
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class AbstractBooleanSetTestCase method retainAll_iterable.
@Override
@Test
public void retainAll_iterable() {
super.retainAll_iterable();
Assert.assertFalse(this.emptySet.retainAll(new BooleanArrayList()));
Assert.assertTrue(this.setWithTrueFalse.retainAll(BooleanArrayList.newListWith(true, true)));
Assert.assertEquals(BooleanHashSet.newSetWith(true), this.setWithTrueFalse);
MutableBooleanSet set = this.newWith(true, false);
Assert.assertTrue(set.retainAll(BooleanArrayList.newListWith()));
Assert.assertEquals(BooleanHashSet.newSetWith(), set);
MutableBooleanSet sett = this.newWith(true, false);
Assert.assertTrue(sett.retainAll(BooleanArrayList.newListWith(false, false)));
Assert.assertEquals(BooleanHashSet.newSetWith(false), sett);
MutableBooleanSet sett2 = this.newWith(true);
Assert.assertTrue(sett2.retainAll(BooleanArrayList.newListWith(false, false)));
Assert.assertEquals(BooleanHashSet.newSetWith(), sett2);
Assert.assertTrue(this.setWithTrue.retainAll(BooleanArrayList.newListWith(false, false)));
Assert.assertFalse(this.setWithTrue.retainAll(BooleanArrayList.newListWith(true, false)));
Assert.assertEquals(BooleanHashSet.newSetWith(), this.setWithTrue);
MutableBooleanSet sett3 = this.newWith(false);
Assert.assertFalse(sett3.retainAll(BooleanArrayList.newListWith(false, false)));
Assert.assertEquals(BooleanHashSet.newSetWith(false), sett3);
Assert.assertTrue(this.setWithFalse.retainAll(BooleanArrayList.newListWith(true, true)));
Assert.assertFalse(this.setWithFalse.retainAll(BooleanArrayList.newListWith(true, false)));
Assert.assertEquals(BooleanHashSet.newSetWith(), this.setWithFalse);
Assert.assertFalse(this.emptySet.retainAll(BooleanArrayList.newListWith(true, true)));
Assert.assertFalse(this.emptySet.retainAll(BooleanArrayList.newListWith(true, false)));
Assert.assertFalse(this.emptySet.retainAll(BooleanArrayList.newListWith(false, false)));
Assert.assertEquals(BooleanHashSet.newSetWith(), this.emptySet);
}
use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.
the class AbstractBooleanSetTestCase method toList.
@Override
@Test
public void toList() {
super.toList();
Assert.assertEquals(new BooleanArrayList(), this.emptySet.toList());
Assert.assertEquals(BooleanArrayList.newListWith(false), this.setWithFalse.toList());
Assert.assertEquals(BooleanArrayList.newListWith(true), this.setWithTrue.toList());
Assert.assertTrue(BooleanArrayList.newListWith(false, true).equals(this.setWithTrueFalse.toList()) || BooleanArrayList.newListWith(true, false).equals(this.setWithTrueFalse.toList()));
}
Aggregations