Search in sources :

Example 11 with LongIterable

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

the class AbstractLongIterableTestCase method newCollectionWith.

@Test
public void newCollectionWith() {
    LongIterable iterable = this.newWith(1L, 2L, 3L);
    Verify.assertSize(3, iterable);
    Verify.assertSize(4, this.newWith(0L, 1L, 31L, 32L));
    Assert.assertTrue(iterable.containsAll(1L, 2L, 3L));
    LongIterable iterable1 = this.newWith();
    Verify.assertEmpty(iterable1);
    Assert.assertFalse(iterable1.containsAll(1L, 2L, 3L));
    LongIterable iterable2 = this.newWith(1L);
    Verify.assertSize(1, iterable2);
    Assert.assertFalse(iterable2.containsAll(1L, 2L, 3L));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 12 with LongIterable

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

Example 13 with LongIterable

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

the class AbstractLongIterableTestCase method toList.

@Test
public void toList() {
    LongIterable iterable = this.newWith(31L, 32L);
    Assert.assertTrue(LongArrayList.newListWith(31L, 32L).equals(iterable.toList()) || LongArrayList.newListWith(32L, 31L).equals(iterable.toList()));
    Assert.assertEquals(LongArrayList.newListWith(0L), this.newWith(0L).toList());
    Assert.assertEquals(LongArrayList.newListWith(31L), this.newWith(31L).toList());
    Assert.assertEquals(LongArrayList.newListWith(32L), this.newWith(32L).toList());
    Assert.assertEquals(new LongArrayList(), this.newWith().toList());
}
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 14 with LongIterable

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

the class AbstractLongLongMapTestCase method select_value.

@Test
public void select_value() {
    LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
    LongIterable actual1 = map.select(LongPredicates.greaterThan(1L));
    Assert.assertEquals(LongBags.immutable.with(2L, 3L), actual1);
    LongIterable actual2 = map.select(LongPredicates.lessThan(2L));
    Assert.assertEquals(LongBags.immutable.with(0L, 1L), actual2);
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 15 with LongIterable

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

the class LongLongHashMapValuesTest method select.

@Override
@Test
public void select() {
    LongIterable iterable = this.classUnderTest();
    Verify.assertSize(3, iterable.select(LongPredicates.lessThan(4L)));
    Verify.assertSize(2, iterable.select(LongPredicates.lessThan(3L)));
}
Also used : 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