use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method contains.
@Test
public void contains() {
LongIterable iterable = this.newWith(14L, 2L, 30L, 31L, 32L, 35L, 0L, 1L);
Assert.assertFalse(iterable.contains(29L));
Assert.assertFalse(iterable.contains(49L));
long[] numbers = { 14L, 2L, 30L, 31L, 32L, 35L, 0L, 1L };
for (long number : numbers) {
Assert.assertTrue(iterable.contains(number));
}
Assert.assertFalse(iterable.contains(-1L));
Assert.assertFalse(iterable.contains(29L));
Assert.assertFalse(iterable.contains(49L));
LongIterable iterable1 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
Assert.assertTrue(iterable1.contains(0L));
Assert.assertTrue(iterable1.contains(1L));
Assert.assertTrue(iterable1.contains(2L));
Assert.assertFalse(iterable1.contains(3L));
LongIterable iterable2 = this.classUnderTest();
for (long each = 1; each <= iterable2.size(); each++) {
Assert.assertTrue(iterable2.contains(each));
}
Assert.assertFalse(iterable2.contains(iterable2.size() + 1));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method makeString.
@Test
public void makeString() {
LongIterable iterable = this.classUnderTest();
Assert.assertEquals("1", this.newWith(1L).makeString("/"));
Assert.assertEquals("31", this.newWith(31L).makeString());
Assert.assertEquals("32", this.newWith(32L).makeString());
Assert.assertEquals(iterable.toString(), iterable.makeString("[", ", ", "]"));
Assert.assertEquals("", this.newWith().makeString());
Assert.assertEquals("", this.newWith().makeString("/"));
Assert.assertEquals("[]", this.newWith().makeString("[", ", ", "]"));
LongIterable iterable1 = this.newWith(0L, 31L);
Assert.assertTrue(iterable1.makeString(), iterable1.makeString().equals("0, 31") || iterable1.makeString().equals("31, 0"));
LongIterable iterable2 = this.newWith(31L, 32L);
Assert.assertTrue(iterable2.makeString("[", "/", "]"), iterable2.makeString("[", "/", "]").equals("[31/32]") || iterable2.makeString("[", "/", "]").equals("[32/31]"));
LongIterable iterable3 = this.newWith(32L, 33L);
Assert.assertTrue(iterable3.makeString("/"), iterable3.makeString("/").equals("32/33") || iterable3.makeString("/").equals("33/32"));
LongIterable iterable4 = this.newWith(1L, 2L);
Assert.assertTrue("1, 2".equals(iterable4.makeString()) || "2, 1".equals(iterable4.makeString()));
Assert.assertTrue("1/2".equals(iterable4.makeString("/")) || "2/1".equals(iterable4.makeString("/")));
Assert.assertTrue("[1/2]".equals(iterable4.makeString("[", "/", "]")) || "[2/1]".equals(iterable4.makeString("[", "/", "]")));
LongIterable iterable5 = this.newWith(0L, 1L);
Assert.assertTrue(iterable5.makeString(), iterable5.makeString().equals("0, 1") || iterable5.makeString().equals("1, 0"));
Assert.assertTrue(iterable5.makeString("[", "/", "]"), iterable5.makeString("[", "/", "]").equals("[0/1]") || iterable5.makeString("[", "/", "]").equals("[1/0]"));
Assert.assertTrue(iterable5.makeString("/"), iterable5.makeString("/").equals("0/1") || iterable5.makeString("/").equals("1/0"));
}
use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.
the class AbstractLongIterableTestCase method allSatisfy.
@Test
public void allSatisfy() {
Assert.assertFalse(this.newWith(1L, 0L, 2L).allSatisfy(LongPredicates.greaterThan(0L)));
Assert.assertTrue(this.newWith(1L, 2L, 3L).allSatisfy(LongPredicates.greaterThan(0L)));
Assert.assertFalse(this.newWith(1L, 0L, 31L, 32L).allSatisfy(LongPredicates.greaterThan(0L)));
Assert.assertFalse(this.newWith(1L, 0L, 31L, 32L).allSatisfy(LongPredicates.greaterThan(0L)));
Assert.assertTrue(this.newWith(1L, 2L, 31L, 32L).allSatisfy(LongPredicates.greaterThan(0L)));
Assert.assertFalse(this.newWith(32L).allSatisfy(LongPredicates.equal(33L)));
Assert.assertFalse(this.newWith(-32L + 100).allSatisfy(LongPredicates.equal(33L + 100)));
LongIterable iterable = this.newWith(0L, 1L, 2L);
Assert.assertFalse(iterable.allSatisfy(value -> 3L < value));
Assert.assertTrue(iterable.allSatisfy(LongPredicates.lessThan(3L)));
LongIterable iterable1 = this.classUnderTest();
int size = iterable1.size();
Assert.assertEquals(size == 0, iterable1.allSatisfy(LongPredicates.greaterThan(3L)));
Assert.assertEquals(size < 3, iterable1.allSatisfy(LongPredicates.lessThan(3L)));
}
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