Search in sources :

Example 26 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method testToString.

@Test
public void testToString() {
    Assert.assertEquals("[]", this.newWith().toString());
    Assert.assertEquals("[1]", this.newWith(1L).toString());
    Assert.assertEquals("[31]", this.newWith(31L).toString());
    Assert.assertEquals("[32]", this.newWith(32L).toString());
    LongIterable iterable = this.newWith(1L, 2L);
    Assert.assertTrue("[1, 2]".equals(iterable.toString()) || "[2, 1]".equals(iterable.toString()));
    LongIterable iterable1 = this.newWith(0L, 31L);
    Assert.assertTrue(iterable1.toString(), iterable1.toString().equals("[0, 31]") || iterable1.toString().equals("[31, 0]"));
    LongIterable iterable2 = this.newWith(31L, 32L);
    Assert.assertTrue(iterable2.toString(), iterable2.toString().equals("[31, 32]") || iterable2.toString().equals("[32, 31]"));
    LongIterable iterable3 = this.newWith(32L, 33L);
    Assert.assertTrue(iterable3.toString(), iterable3.toString().equals("[32, 33]") || iterable3.toString().equals("[33, 32]"));
    LongIterable iterable4 = this.newWith(0L, 1L);
    Assert.assertTrue(iterable4.toString(), iterable4.toString().equals("[0, 1]") || iterable4.toString().equals("[1, 0]"));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 27 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method containsAllArray.

@Test
public void containsAllArray() {
    Assert.assertTrue(this.classUnderTest().containsAll(this.classUnderTest().toArray()));
    Assert.assertFalse(this.classUnderTest().containsAll(this.classUnderTest().size() + 1));
    LongIterable iterable = this.newWith(1L, 2L, 3L);
    Assert.assertTrue(iterable.containsAll(1L));
    Assert.assertTrue(iterable.containsAll(1L, 2L, 3L));
    Assert.assertFalse(iterable.containsAll(1L, 2L, 3L, 4L));
    Assert.assertFalse(iterable.containsAll(1L, 2L, 4L));
    Assert.assertFalse(iterable.containsAll(4L, 5L, 6L));
    LongIterable iterable1 = this.newWith(14L, 2L, 30L, 32L, 35L, 0L, 1L);
    Assert.assertTrue(iterable1.containsAll(14L));
    Assert.assertTrue(iterable1.containsAll(35L));
    Assert.assertFalse(iterable1.containsAll(-1L));
    Assert.assertTrue(iterable1.containsAll(14L, 1L, 30L));
    Assert.assertTrue(iterable1.containsAll(14L, 1L, 32L));
    Assert.assertTrue(iterable1.containsAll(14L, 1L, 35L));
    Assert.assertFalse(iterable1.containsAll(0L, 2L, 35L, -1L));
    Assert.assertFalse(iterable1.containsAll(31L, -1L));
    LongIterable iterable2 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
    Assert.assertTrue(iterable2.containsAll(0L));
    Assert.assertTrue(iterable2.containsAll(0L, 0L, 0L));
    Assert.assertTrue(iterable2.containsAll(0L, 1L, 1L));
    Assert.assertTrue(iterable2.containsAll(0L, 1L, 2L));
    Assert.assertFalse(iterable2.containsAll(0L, 1L, 2L, 3L, 4L));
    Assert.assertFalse(iterable2.containsAll(3L, 4L));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 28 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method select.

@Test
public void select() {
    LongIterable iterable = this.classUnderTest();
    int size = iterable.size();
    Verify.assertSize(size >= 3 ? 3 : size, iterable.select(LongPredicates.lessThan(4L)));
    Verify.assertSize(size >= 2 ? 2 : size, iterable.select(LongPredicates.lessThan(3L)));
    LongIterable iterable1 = this.newWith(0L, 1L, 2L, 2L, 3L, 3L, 3L);
    Assert.assertEquals(this.newMutableCollectionWith(0L, 1L), iterable1.select(LongPredicates.lessThan(2L)));
    Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 3L, 3L, 3L), iterable1.select(LongPredicates.greaterThan(1L)));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 29 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method noneSatisfy.

@Test
public void noneSatisfy() {
    Assert.assertFalse(this.newWith(1L, 0L, 2L).noneSatisfy(LongPredicates.greaterThan(0L)));
    Assert.assertFalse(this.newWith(1L, 0L, 2L).noneSatisfy(LongPredicates.equal(0L)));
    Assert.assertTrue(this.newWith(1L, 2L, 3L).noneSatisfy(LongPredicates.greaterThan(3L)));
    Assert.assertFalse(this.newWith(1L, 0L, 31L, 32L).noneSatisfy(LongPredicates.greaterThan(0L)));
    Assert.assertFalse(this.newWith(1L, 0L, 31L, 32L).noneSatisfy(LongPredicates.greaterThan(0L)));
    Assert.assertTrue(this.newWith(1L, 2L, 31L, 32L).noneSatisfy(LongPredicates.lessThan(0L)));
    Assert.assertFalse(this.newWith(32L).noneSatisfy(LongPredicates.greaterThan(0L)));
    LongIterable iterable = this.newWith(0L, 1L, 2L);
    Assert.assertFalse(iterable.noneSatisfy(value -> 1L < value));
    Assert.assertTrue(iterable.noneSatisfy(LongPredicates.greaterThan(3L)));
    LongIterable iterable1 = this.classUnderTest();
    int size = iterable1.size();
    Assert.assertEquals(size <= 3, iterable1.noneSatisfy(LongPredicates.greaterThan(3L)));
    Assert.assertEquals(size == 0, iterable1.noneSatisfy(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)

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