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());
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method toArray.
@Test
public void toArray() {
Assert.assertEquals(this.classUnderTest().size(), this.classUnderTest().toArray().length);
LongIterable iterable = this.newWith(1L, 2L);
Assert.assertTrue(Arrays.equals(new long[] { 1L, 2L }, iterable.toArray()) || Arrays.equals(new long[] { 2L, 1L }, iterable.toArray()));
Assert.assertTrue(Arrays.equals(new long[] { 0L, 1L }, this.newWith(0L, 1L).toArray()) || Arrays.equals(new long[] { 1L, 0L }, this.newWith(0L, 1L).toArray()));
Assert.assertTrue(Arrays.equals(new long[] { 1L, 31L }, this.newWith(1L, 31L).toArray()) || Arrays.equals(new long[] { 31L, 1L }, this.newWith(1L, 31L).toArray()));
Assert.assertTrue(Arrays.equals(new long[] { 31L, 35L }, this.newWith(31L, 35L).toArray()) || Arrays.equals(new long[] { 35L, 31L }, this.newWith(31L, 35L).toArray()));
Assert.assertArrayEquals(new long[] {}, this.newWith().toArray());
Assert.assertArrayEquals(new long[] { 32L }, this.newWith(32L).toArray());
}
Aggregations