Search in sources :

Example 21 with MutableByteSet

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

the class AbstractByteSetTestCase method count.

@Override
@Test
public void count() {
    super.count();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 65, (byte) 100, (byte) 127, (byte) 12, (byte) -76, (byte) -1, (byte) -54, (byte) -64, (byte) -63, (byte) -95, (byte) -128, (byte) -127);
    Assert.assertEquals(7L, set.count(BytePredicates.greaterThan((byte) 0)));
    Assert.assertEquals(12L, set.count(BytePredicates.lessThan((byte) 32)));
    Assert.assertEquals(4L, set.count(BytePredicates.greaterThan((byte) 32)));
    Assert.assertEquals(1L, set.count(BytePredicates.greaterThan((byte) 100)));
    Assert.assertEquals(14L, set.count(BytePredicates.lessThan((byte) 100)));
    Assert.assertEquals(7L, set.count(BytePredicates.lessThan((byte) -50)));
    Assert.assertEquals(6L, set.count(BytePredicates.lessThan((byte) -54)));
    Assert.assertEquals(15L, set.count(BytePredicates.greaterThan((byte) -128)));
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 22 with MutableByteSet

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

the class AbstractByteSetTestCase method asUnmodifiable.

@Override
@Test
public void asUnmodifiable() {
    super.asUnmodifiable();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -31, (byte) -24);
    Verify.assertInstanceOf(UnmodifiableByteSet.class, set.asUnmodifiable());
    Assert.assertEquals(new UnmodifiableByteSet(set), set.asUnmodifiable());
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 23 with MutableByteSet

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

the class AbstractByteSetTestCase method select.

@Override
@Test
public void select() {
    super.select();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 65, (byte) 100, (byte) 127, (byte) 12, (byte) -76, (byte) -1, (byte) -54, (byte) -64, (byte) -63, (byte) -95, (byte) -128, (byte) -127);
    Assert.assertEquals(this.newWith((byte) 63, (byte) 65, (byte) 100, (byte) 127), set.select(BytePredicates.greaterThan((byte) 32)));
    Assert.assertEquals(this.newWith((byte) -76, (byte) -1, (byte) -54, (byte) -64, (byte) -63, (byte) -95, (byte) -128, (byte) -127), set.select(BytePredicates.lessThan((byte) 0)));
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 24 with MutableByteSet

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

the class AbstractByteSetTestCase method testEquals.

@Override
@Test
public void testEquals() {
    super.testEquals();
    MutableByteSet set1 = this.newWith((byte) 1, (byte) 31, (byte) 32);
    MutableByteSet set2 = this.newWith((byte) 32, (byte) 31, (byte) 1);
    MutableByteSet set3 = this.newWith((byte) 32, (byte) 32, (byte) 31, (byte) 1);
    MutableByteSet set4 = this.newWith((byte) 32, (byte) 32, (byte) 31, (byte) 1, (byte) 1);
    Verify.assertEqualsAndHashCode(set1, set2);
    Verify.assertEqualsAndHashCode(set1, set3);
    Verify.assertEqualsAndHashCode(set1, set4);
    Verify.assertEqualsAndHashCode(set2, set3);
    Verify.assertEqualsAndHashCode(set2, set4);
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 25 with MutableByteSet

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

the class ByteHashSetTest method reject.

@Override
@Test
public void reject() {
    super.reject();
    ByteHashSet set = ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -2, (byte) -64, (byte) -128, (byte) 64);
    MutableByteSet actualSet = set.reject(BytePredicates.greaterThan((byte) 0));
    ByteHashSet expectedSet = ByteHashSet.newSetWith((byte) 0, (byte) -1, (byte) -2, (byte) -64, (byte) -128);
    Assert.assertEquals(expectedSet, actualSet);
    MutableByteSet actualSet2 = set.reject(BytePredicates.lessThan((byte) 0));
    ByteHashSet expectedSet2 = ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) 64);
    Assert.assertEquals(expectedSet2, actualSet2);
}
Also used : 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