use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method reject_value.
@Test
public void reject_value() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
LongIterable actual1 = map.reject(LongPredicates.lessThan(2L));
Assert.assertEquals(LongBags.immutable.with(2L, 3L), actual1);
LongIterable actual2 = map.reject(LongPredicates.greaterThan(1L));
Assert.assertEquals(LongBags.immutable.with(0L, 1L), actual2);
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method reject.
@Test
public void reject() {
LongIterable iterable = this.classUnderTest();
int size = iterable.size();
Verify.assertSize(size <= 3 ? 0 : size - 3, iterable.reject(LongPredicates.lessThan(4L)));
Verify.assertSize(size <= 2 ? 0 : size - 2, iterable.reject(LongPredicates.lessThan(3L)));
LongIterable iterable1 = this.newWith(0L, 1L, 2L, 2L, 3L, 3L, 3L);
Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 3L, 3L, 3L), iterable1.reject(LongPredicates.lessThan(2L)));
Assert.assertEquals(this.newMutableCollectionWith(0L, 1L), iterable1.reject(LongPredicates.greaterThan(1L)));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method injectInto.
@Test
public void injectInto() {
LongIterable iterable1 = this.newWith(0L, 2L, 31L);
Long sum1 = iterable1.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value + 1)));
Assert.assertEquals(Long.valueOf(36L), sum1);
LongIterable iterable2 = this.newWith(1L, 2L, 31L);
Long sum2 = iterable2.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value + 1)));
Assert.assertEquals(Long.valueOf(37L), sum2);
LongIterable iterable3 = this.newWith(0L, 1L, 2L, 31L);
Long sum3 = iterable3.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value + 1)));
Assert.assertEquals(Long.valueOf(38L), sum3);
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method longIterator_throws_non_empty_collection.
@Test(expected = NoSuchElementException.class)
public void longIterator_throws_non_empty_collection() {
LongIterable iterable = this.newWith(1L, 2L, 3L);
LongIterator iterator = iterable.longIterator();
while (iterator.hasNext()) {
iterator.next();
}
iterator.next();
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method asLazy.
@Test
public void asLazy() {
LongIterable iterable = this.classUnderTest();
Assert.assertEquals(iterable.toBag(), iterable.asLazy().toBag());
Verify.assertInstanceOf(LazyLongIterable.class, iterable.asLazy());
LongIterable iterable1 = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
Assert.assertEquals(iterable1.toBag(), iterable1.asLazy().toBag());
Verify.assertInstanceOf(LazyLongIterable.class, iterable1.asLazy());
LongIterable iterable2 = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
Assert.assertEquals(iterable2.toBag(), iterable2.asLazy().toBag());
Verify.assertInstanceOf(LazyLongIterable.class, iterable2.asLazy());
LongIterable iterable3 = this.newWith();
Assert.assertEquals(iterable3.toBag(), iterable3.asLazy().toBag());
Verify.assertInstanceOf(LazyLongIterable.class, iterable3.asLazy());
LongIterable iterable4 = this.newWith(1L);
Assert.assertEquals(iterable4.toBag(), iterable4.asLazy().toBag());
Verify.assertInstanceOf(LazyLongIterable.class, iterable4.asLazy());
}
Aggregations