Search in sources :

Example 16 with MutableByteSet

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

the class AbstractByteSetTestCase method add.

@Override
@Test
public void add() {
    super.add();
    MutableByteSet set = this.newWith();
    Assert.assertTrue(set.add((byte) 14));
    Assert.assertFalse(set.add((byte) 14));
    Assert.assertTrue(set.add((byte) 2));
    Assert.assertFalse(set.add((byte) 2));
    Assert.assertTrue(set.add((byte) 35));
    Assert.assertFalse(set.add((byte) 35));
    Assert.assertTrue(set.add((byte) 31));
    Assert.assertFalse(set.add((byte) 31));
    Assert.assertTrue(set.add((byte) 32));
    Assert.assertFalse(set.add((byte) 32));
    Assert.assertTrue(set.add((byte) 0));
    Assert.assertFalse(set.add((byte) 0));
    Assert.assertTrue(set.add((byte) 1));
    Assert.assertFalse(set.add((byte) 1));
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 17 with MutableByteSet

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

the class AbstractByteSetTestCase method detectIfNone.

@Override
@Test
public void detectIfNone() {
    super.detectIfNone();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 64, (byte) 127, (byte) -1, (byte) -67, (byte) -128, (byte) -63);
    Assert.assertEquals(127, set.detectIfNone(BytePredicates.greaterThan((byte) 126), (byte) 9));
    Assert.assertEquals(127, set.detectIfNone(BytePredicates.greaterThan((byte) 64), (byte) 9));
    Assert.assertEquals(-128, set.detectIfNone(BytePredicates.lessThan((byte) -68), (byte) 9));
    MutableByteSet set1 = this.newWith((byte) 0, (byte) -1, (byte) 12, (byte) 64);
    Assert.assertEquals(-1, set1.detectIfNone(BytePredicates.lessThan((byte) 0), (byte) 9));
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 18 with MutableByteSet

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

the class AbstractByteSetTestCase method addAllIterable.

@Override
@Test
public void addAllIterable() {
    super.addAllIterable();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -128);
    Assert.assertFalse(set.addAll(new ByteArrayList()));
    Assert.assertFalse(set.addAll(ByteArrayList.newListWith((byte) 31, (byte) -1, (byte) -128)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -128), set);
    Assert.assertTrue(set.addAll(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 2, (byte) 30, (byte) -1, (byte) -128)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 2, (byte) 30, (byte) 31, (byte) -1, (byte) -128), set);
    Assert.assertTrue(set.addAll(ByteHashSet.newSetWith((byte) 5)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 2, (byte) 5, (byte) 30, (byte) 31, (byte) 31, (byte) -1, (byte) -128), set);
    ByteHashSet set1 = new ByteHashSet();
    Assert.assertTrue(set1.addAll((byte) 2, (byte) 35));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 2, (byte) 35), set1);
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 19 with MutableByteSet

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

the class AbstractByteSetTestCase method byteIterator.

@Override
@Test
public void byteIterator() {
    MutableSet<Byte> expected = UnifiedSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64, (byte) -100, (byte) -128);
    MutableSet<Byte> actual = UnifiedSet.newSet();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64, (byte) -100, (byte) -128);
    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.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    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.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    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) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 20 with MutableByteSet

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

the class AbstractByteSetTestCase method removeAll_iterable.

@Override
@Test
public void removeAll_iterable() {
    super.removeAll_iterable();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64, (byte) -100, (byte) -128);
    Assert.assertFalse(set.removeAll(new ByteArrayList()));
    Assert.assertFalse(set.removeAll(ByteArrayList.newListWith((byte) 15, (byte) 98, (byte) -98, (byte) -127)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64, (byte) -100, (byte) -128), set);
    Assert.assertTrue(set.removeAll(ByteHashSet.newSetWith((byte) 0, (byte) 31, (byte) -128, (byte) -100)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 1, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64), set);
    Assert.assertTrue(set.removeAll(ByteHashSet.newSetWith((byte) 1, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64)));
    Assert.assertEquals(new ByteHashSet(), set);
    Assert.assertFalse(set.removeAll(ByteHashSet.newSetWith((byte) 1)));
    Assert.assertEquals(new ByteHashSet(), set);
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Aggregations

MutableByteSet (org.eclipse.collections.api.set.primitive.MutableByteSet)25 Test (org.junit.Test)21 ByteIterator (org.eclipse.collections.api.iterator.ByteIterator)4 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)3 LazyByteIterable (org.eclipse.collections.api.LazyByteIterable)2 ByteHashSet (org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet)2 NoSuchElementException (java.util.NoSuchElementException)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 MutableByteIterator (org.eclipse.collections.api.iterator.MutableByteIterator)1 MutableSet (org.eclipse.collections.api.set.MutableSet)1 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)1 BytePredicates (org.eclipse.collections.impl.block.factory.primitive.BytePredicates)1 AbstractMutableByteCollectionTestCase (org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableByteCollectionTestCase)1 ByteSets (org.eclipse.collections.impl.factory.primitive.ByteSets)1 UnifiedSet (org.eclipse.collections.impl.set.mutable.UnifiedSet)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1