Search in sources :

Example 26 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method longIterator_throws_for_consecutive_remove.

@Test
public void longIterator_throws_for_consecutive_remove() {
    MutableLongCollection longIterable = this.classUnderTest();
    final MutableLongIterator iterator = longIterable.longIterator();
    Assert.assertTrue(iterator.hasNext());
    iterator.next();
    iterator.remove();
    Verify.assertThrows(IllegalStateException.class, new Runnable() {

        @Override
        public void run() {
            iterator.remove();
        }
    });
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) MutableLongIterator(org.eclipse.collections.api.iterator.MutableLongIterator) Test(org.junit.Test)

Example 27 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method remove.

@Test
public void remove() {
    MutableLongCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.remove(-1L));
    Assert.assertEquals(this.newMutableCollectionWith(1L, 2L, 3L), collection);
    Assert.assertTrue(collection.remove(3L));
    Assert.assertEquals(this.newMutableCollectionWith(1L, 2L), collection);
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 28 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method asUnmodifiable.

@Test
public void asUnmodifiable() {
    Verify.assertInstanceOf(this.newWith(1L, 2L, 3L).asUnmodifiable().getClass(), this.classUnderTest().asUnmodifiable());
    Assert.assertEquals(this.newWith(1L, 2L, 3L).asUnmodifiable(), this.classUnderTest().asUnmodifiable());
    MutableLongCollection collection = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
    MutableLongCollection unmodifiableCollection = this.newWith(1L, 2L, 2L, 3L, 3L, 3L).asUnmodifiable();
    Verify.assertInstanceOf(unmodifiableCollection.getClass(), collection.asUnmodifiable());
    Assert.assertEquals(unmodifiableCollection, collection.asUnmodifiable());
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 29 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method add.

@Test
public void add() {
    MutableLongCollection emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.add(1L));
    Assert.assertEquals(this.newMutableCollectionWith(1L), emptyCollection);
    MutableLongCollection collection = this.classUnderTest();
    Assert.assertTrue(collection.add(4L));
    Assert.assertEquals(this.newMutableCollectionWith(1L, 2L, 3L, 4L), collection);
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 30 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method longIterator_throws_non_empty_collection.

@Override
@Test(expected = NoSuchElementException.class)
public void longIterator_throws_non_empty_collection() {
    super.longIterator_throws_non_empty_collection();
    MutableLongCollection collection = this.newWith();
    collection.add(1L);
    collection.add(2L);
    collection.add(3L);
    LongIterator iterator = collection.longIterator();
    while (iterator.hasNext()) {
        iterator.next();
    }
    iterator.next();
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) LongIterator(org.eclipse.collections.api.iterator.LongIterator) MutableLongIterator(org.eclipse.collections.api.iterator.MutableLongIterator) Test(org.junit.Test)

Aggregations

MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)30 Test (org.junit.Test)30 MutableLongLongMap (org.eclipse.collections.api.map.primitive.MutableLongLongMap)6 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)5 MutableLongIterator (org.eclipse.collections.api.iterator.MutableLongIterator)4 LongIterator (org.eclipse.collections.api.iterator.LongIterator)2 Ignore (org.junit.Ignore)2