Search in sources :

Example 11 with ImmutableByteSet

use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.

the class AbstractImmutableByteHashSetTestCase method byteIterator.

@Override
@Test
public void byteIterator() {
    MutableSet<Byte> expected = UnifiedSet.newSetWith((byte) 0, (byte) 1, (byte) 31);
    MutableSet<Byte> actual = UnifiedSet.newSet();
    ImmutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31);
    ByteIterator iterator = set.byteIterator();
    Assert.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    Assert.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    Assert.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    Assert.assertFalse(iterator.hasNext());
    Assert.assertEquals(expected, actual);
    Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator::next);
}
Also used : ByteIterator(org.eclipse.collections.api.iterator.ByteIterator) ImmutableByteSet(org.eclipse.collections.api.set.primitive.ImmutableByteSet) Test(org.junit.Test)

Example 12 with ImmutableByteSet

use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.

the class AbstractImmutableByteHashSetTestCase method toSortedArray.

@Override
@Test
public void toSortedArray() {
    super.toSortedArray();
    ImmutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31);
    Assert.assertArrayEquals(new byte[] { (byte) 0, (byte) 1, (byte) 31 }, set.toSortedArray());
}
Also used : ImmutableByteSet(org.eclipse.collections.api.set.primitive.ImmutableByteSet) Test(org.junit.Test)

Example 13 with ImmutableByteSet

use of org.eclipse.collections.api.set.primitive.ImmutableByteSet in project eclipse-collections by eclipse.

the class AbstractImmutableByteHashSetTestCase method count.

@Override
@Test
public void count() {
    super.count();
    ImmutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 127, (byte) -1, (byte) -31, (byte) -64, (byte) -65, (byte) -128);
    Assert.assertEquals(3, set.count(BytePredicates.greaterThan((byte) 0)));
    Assert.assertEquals(8, set.count(BytePredicates.lessThan((byte) 32)));
    Assert.assertEquals(1, set.count(BytePredicates.greaterThan((byte) 32)));
}
Also used : ImmutableByteSet(org.eclipse.collections.api.set.primitive.ImmutableByteSet) Test(org.junit.Test)

Aggregations

ImmutableByteSet (org.eclipse.collections.api.set.primitive.ImmutableByteSet)13 Test (org.junit.Test)12 ByteIterator (org.eclipse.collections.api.iterator.ByteIterator)3 NoSuchElementException (java.util.NoSuchElementException)1 Op (nars.Op)1 LazyByteIterable (org.eclipse.collections.api.LazyByteIterable)1 MutableSet (org.eclipse.collections.api.set.MutableSet)1 MutableByteSet (org.eclipse.collections.api.set.primitive.MutableByteSet)1 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)1 BytePredicates (org.eclipse.collections.impl.block.factory.primitive.BytePredicates)1 AbstractImmutableByteCollectionTestCase (org.eclipse.collections.impl.collection.immutable.primitive.AbstractImmutableByteCollectionTestCase)1 UnifiedSet (org.eclipse.collections.impl.set.mutable.UnifiedSet)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1