Search in sources :

Example 6 with LongIterable

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)));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) Arrays(java.util.Arrays) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) LongIterator(org.eclipse.collections.api.iterator.LongIterator) RichIterable(org.eclipse.collections.api.RichIterable) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) LongIterable(org.eclipse.collections.api.LongIterable) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LongToObjectFunction(org.eclipse.collections.api.block.function.primitive.LongToObjectFunction) LongPredicates(org.eclipse.collections.impl.block.factory.primitive.LongPredicates) Assert(org.junit.Assert) NoSuchElementException(java.util.NoSuchElementException) LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 7 with LongIterable

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)));
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 8 with LongIterable

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)));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 9 with LongIterable

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));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 10 with LongIterable

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));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) Arrays(java.util.Arrays) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) LongIterator(org.eclipse.collections.api.iterator.LongIterator) RichIterable(org.eclipse.collections.api.RichIterable) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) LongIterable(org.eclipse.collections.api.LongIterable) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LongToObjectFunction(org.eclipse.collections.api.block.function.primitive.LongToObjectFunction) LongPredicates(org.eclipse.collections.impl.block.factory.primitive.LongPredicates) Assert(org.junit.Assert) NoSuchElementException(java.util.NoSuchElementException) LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Aggregations

LongIterable (org.eclipse.collections.api.LongIterable)29 Test (org.junit.Test)29 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)24 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)6 LongIterator (org.eclipse.collections.api.iterator.LongIterator)5 Arrays (java.util.Arrays)4 NoSuchElementException (java.util.NoSuchElementException)4 RichIterable (org.eclipse.collections.api.RichIterable)4 LongToObjectFunction (org.eclipse.collections.api.block.function.primitive.LongToObjectFunction)4 LongHashBag (org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)4 LongPredicates (org.eclipse.collections.impl.block.factory.primitive.LongPredicates)4 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)4 Verify (org.eclipse.collections.impl.test.Verify)4 Assert (org.junit.Assert)4 ImmutableLongLongMap (org.eclipse.collections.api.map.primitive.ImmutableLongLongMap)2 LongLongMap (org.eclipse.collections.api.map.primitive.LongLongMap)2