use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.
the class UnmodifiableBooleanBagTest method iterator_throws_on_invocation_of_remove_before_next.
@Override
@Test
public void iterator_throws_on_invocation_of_remove_before_next() {
MutableBooleanIterator booleanIterator = this.classUnderTest().booleanIterator();
Assert.assertTrue(booleanIterator.hasNext());
Verify.assertThrows(UnsupportedOperationException.class, booleanIterator::remove);
}
use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.
the class UnmodifiableBooleanListTest method booleanIterator_with_remove.
@Override
@Test
public void booleanIterator_with_remove() {
MutableBooleanIterator booleanIterator = this.classUnderTest().booleanIterator();
Assert.assertTrue(booleanIterator.hasNext());
booleanIterator.next();
Verify.assertThrows(UnsupportedOperationException.class, booleanIterator::remove);
}
use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.
the class ObjectBooleanHashMapValuesTestCase method booleanIterator.
@Override
@Test
public void booleanIterator() {
MutableBooleanCollection bag = this.newWith(true, false, true, true);
BooleanArrayList list = BooleanArrayList.newListWith(true, false, true, true);
BooleanIterator iterator1 = bag.booleanIterator();
for (int i = 0; i < 4; i++) {
Assert.assertTrue(iterator1.hasNext());
Assert.assertTrue(list.remove(iterator1.next()));
}
Verify.assertEmpty(list);
Assert.assertFalse(iterator1.hasNext());
Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator1::next);
ObjectBooleanHashMap<String> map2 = new ObjectBooleanHashMap<>();
for (int each = 2; each < 100; each++) {
map2.put(String.valueOf(each), each % 2 == 0);
}
MutableBooleanIterator iterator2 = map2.booleanIterator();
while (iterator2.hasNext()) {
iterator2.next();
iterator2.remove();
}
Assert.assertTrue(map2.isEmpty());
}
use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.
the class AbstractMutableObjectBooleanMapTestCase method iterator_throws_on_consecutive_invocation_of_remove.
@Test
public void iterator_throws_on_consecutive_invocation_of_remove() {
MutableObjectBooleanMap<String> map = this.classUnderTest();
Verify.assertNotEmpty(map);
MutableBooleanIterator booleanIterator = map.booleanIterator();
Assert.assertTrue(booleanIterator.hasNext());
booleanIterator.next();
booleanIterator.remove();
Verify.assertThrows(IllegalStateException.class, booleanIterator::remove);
}
use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.
the class BooleanHashSetTest method booleanIterator_with_remove.
@Override
@Test
public void booleanIterator_with_remove() {
super.booleanIterator_with_remove();
BooleanHashSet falseSet = this.newWith(false);
MutableBooleanIterator mutableBooleanIterator = falseSet.booleanIterator();
Assert.assertTrue(mutableBooleanIterator.hasNext());
Assert.assertFalse(mutableBooleanIterator.next());
mutableBooleanIterator.remove();
Verify.assertEmpty(falseSet);
Verify.assertThrows(NoSuchElementException.class, mutableBooleanIterator::next);
Verify.assertThrows(IllegalStateException.class, mutableBooleanIterator::remove);
BooleanHashSet trueSet = this.newWith(true);
mutableBooleanIterator = trueSet.booleanIterator();
Assert.assertTrue(mutableBooleanIterator.hasNext());
Assert.assertTrue(mutableBooleanIterator.next());
mutableBooleanIterator.remove();
Verify.assertEmpty(trueSet);
Verify.assertThrows(NoSuchElementException.class, mutableBooleanIterator::next);
Verify.assertThrows(IllegalStateException.class, mutableBooleanIterator::remove);
BooleanHashSet emptySet = new BooleanHashSet();
mutableBooleanIterator = emptySet.booleanIterator();
Assert.assertFalse(mutableBooleanIterator.hasNext());
Verify.assertEmpty(emptySet);
Verify.assertThrows(NoSuchElementException.class, mutableBooleanIterator::next);
Verify.assertThrows(IllegalStateException.class, mutableBooleanIterator::remove);
}
Aggregations