use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method anySatisfy.
@Test
public void anySatisfy() {
Assert.assertTrue(this.newWith(1L + 100, -1L + 100, 2L + 100).anySatisfy(LongPredicates.greaterThan(0L + 100)));
Assert.assertFalse(this.newWith(1L + 100, -1L + 100, 2L + 100).anySatisfy(LongPredicates.equal(0L + 100)));
Assert.assertTrue(this.newWith(-1L + 100, -1L + 100, -2L + 100, 31L + 100, 32L + 100).anySatisfy(LongPredicates.greaterThan(0L + 100)));
Assert.assertTrue(this.newWith(2L + 100, -1L + 100, -2L + 100, 31L + 100, 32L + 100).anySatisfy(LongPredicates.greaterThan(0L + 100)));
Assert.assertFalse(this.newWith(1L + 100, -1L + 100, 31L + 100, 32L + 100).anySatisfy(LongPredicates.equal(0L + 100)));
Assert.assertTrue(this.newWith(32L).anySatisfy(LongPredicates.greaterThan(0L)));
LongIterable iterable = this.newWith(0L, 1L, 2L);
Assert.assertTrue(iterable.anySatisfy(value -> value < 3L));
Assert.assertFalse(iterable.anySatisfy(LongPredicates.greaterThan(3L)));
LongIterable iterable1 = this.classUnderTest();
int size = iterable1.size();
Assert.assertEquals(size > 3, iterable1.anySatisfy(LongPredicates.greaterThan(3L)));
Assert.assertEquals(size != 0, iterable1.anySatisfy(LongPredicates.lessThan(3L)));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method containsAllIterable.
@Test
public void containsAllIterable() {
LongIterable source = this.classUnderTest();
Assert.assertTrue(source.containsAll(this.classUnderTest()));
Assert.assertFalse(source.containsAll(LongArrayList.newListWith(source.size() + 1)));
LongIterable iterable = this.newWith(1L, 2L, 3L);
Assert.assertTrue(this.newWith().containsAll(new LongArrayList()));
Assert.assertFalse(this.newWith().containsAll(LongArrayList.newListWith(1L)));
Assert.assertTrue(iterable.containsAll(LongArrayList.newListWith(1L)));
Assert.assertTrue(iterable.containsAll(LongArrayList.newListWith(1L, 2L, 3L)));
Assert.assertFalse(iterable.containsAll(LongArrayList.newListWith(1L, 2L, 3L, 4L)));
Assert.assertFalse(iterable.containsAll(LongArrayList.newListWith(1L, 2L, 4L)));
Assert.assertFalse(iterable.containsAll(LongArrayList.newListWith(4L, 5L, 6L)));
LongIterable iterable1 = this.newWith(14L, 2L, 30L, 32L, 35L, 0L, 1L);
Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L)));
Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(35L)));
Assert.assertFalse(iterable1.containsAll(LongHashSet.newSetWith(-1L)));
Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L, 1L, 30L)));
Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L, 1L, 32L)));
Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L, 1L, 35L)));
Assert.assertFalse(iterable1.containsAll(LongHashSet.newSetWith(0L, 2L, 35L, -1L)));
Assert.assertFalse(iterable1.containsAll(LongHashSet.newSetWith(31L, -1L)));
LongIterable iterable2 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L)));
Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L, 0L, 0L)));
Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L, 1L, 1L)));
Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L, 1L, 2L)));
Assert.assertFalse(iterable2.containsAll(LongArrayList.newListWith(0L, 1L, 2L, 3L, 4L)));
Assert.assertFalse(iterable2.containsAll(LongArrayList.newListWith(3L, 4L)));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method count.
@Test
public void count() {
LongIterable iterable = this.classUnderTest();
int size = iterable.size();
Assert.assertEquals(size >= 3 ? 3 : size, iterable.count(LongPredicates.lessThan(4L)));
Assert.assertEquals(2L, this.newWith(1L, 0L, 2L).count(LongPredicates.greaterThan(0L)));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method testEquals.
@Test
public void testEquals() {
LongIterable iterable1 = this.newWith(1L, 2L, 3L, 4L);
LongIterable iterable2 = this.newWith(1L, 2L, 3L, 4L);
LongIterable iterable3 = this.newWith(5L, 6L, 7L, 8L);
LongIterable iterable4 = this.newWith(5L, 6L, 7L);
LongIterable iterable5 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
LongIterable iterable6 = this.newWith(1L, 31L, 32L);
LongIterable iterable7 = this.newWith(35L, 31L, 1L);
LongIterable iterable8 = this.newWith(32L, 31L, 1L, 50L);
LongIterable iterable9 = this.newWith(0L, 1L, 2L);
LongIterable iterable10 = this.newWith(0L, 1L, 3L);
LongIterable iterable11 = this.newWith(3L, 1L, 2L);
LongIterable iterable12 = this.newWith(3L);
Verify.assertEqualsAndHashCode(iterable1, iterable2);
Verify.assertPostSerializedEqualsAndHashCode(iterable1);
Verify.assertPostSerializedEqualsAndHashCode(iterable12);
Verify.assertPostSerializedEqualsAndHashCode(iterable5);
Verify.assertPostSerializedEqualsAndHashCode(iterable6);
Assert.assertNotEquals(iterable12, iterable11);
Assert.assertNotEquals(iterable1, iterable3);
Assert.assertNotEquals(iterable1, iterable4);
Assert.assertNotEquals(iterable6, iterable7);
Assert.assertNotEquals(iterable6, iterable8);
Assert.assertNotEquals(iterable9, iterable10);
Assert.assertNotEquals(iterable9, iterable11);
Assert.assertNotEquals(this.newWith(), this.newWith(100L));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method collect.
@Test
public void collect() {
LongToObjectFunction<Long> function = parameter -> parameter - 1;
Assert.assertEquals(this.newObjectCollectionWith(0L, 1L, 2L), this.newWith(1L, 2L, 3L).collect(function));
LongIterable iterable = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
Assert.assertEquals(this.newObjectCollectionWith(0L, 1L, 1L, 2L, 2L, 2L), iterable.collect(function));
Assert.assertEquals(this.newObjectCollectionWith(), this.newWith().collect(function));
Assert.assertEquals(this.newObjectCollectionWith(2L), this.newWith(3L).collect(function));
}
Aggregations