Search in sources :

Example 36 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method toString_regular.

@Test
public void toString_regular() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(11);
    intSet.add(22);
    intSet.add(33);
    String toString = intSet.toString();
    assertTrue("ToString output should start with an opening square bracket.", toString.startsWith("["));
    assertTrue("ToString output should end with a closing square bracket.", toString.endsWith("]"));
    assertTrue("ToString output should contain the number 11.", toString.contains("11"));
    assertTrue("ToString output should contain the number 22.", toString.contains("22"));
    assertTrue("ToString output should contain the number 33.", toString.contains("33"));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 37 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method removeAll_disjoint_set.

@Test
public void removeAll_disjoint_set() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(2);
    otherSet.add(3);
    otherSet.add(4);
    intSet.removeAll(otherSet);
    assertEquals("Integer set size should be 3.", 3, intSet.size());
    assertTrue("Integer set should contain element 0.", intSet.contains(0));
    assertTrue("Integer set should contain element 5.", intSet.contains(5));
    assertTrue("Integer set should contain element 10.", intSet.contains(10));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 38 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method add_twice.

@Test
public void add_twice() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    assertTrue("First attempt at adding 0 to the set should modify the set.", intSet.add(0));
    assertTrue("First attempt at adding 5 to the set should modify the set.", intSet.add(5));
    assertFalse("Second attempt at adding 0 to the set should not modify the set.", intSet.add(0));
    assertFalse("Second attempt at adding 5 to the set should not modify the set.", intSet.add(5));
    assertEquals("Integer set size should be 2.", 2, intSet.size());
    assertTrue("Integer set should contain element 0.", intSet.contains(0));
    assertTrue("Integer set should contain element 5.", intSet.contains(5));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 39 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method iterator_overrun.

@Test(expected = NoSuchElementException.class)
public void iterator_overrun() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntIterator itr = intSet.iterator();
    itr.next();
}
Also used : IntIterator(com.b2international.collections.ints.IntIterator) IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 40 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method contains_false_after_remove.

@Test
public void contains_false_after_remove() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    intSet.remove(0);
    intSet.remove(5);
    intSet.remove(10);
    assertEquals("Integer set size should be 0.", 0, intSet.size());
    assertTrue("Integer set should be empty.", intSet.isEmpty());
    assertFalse("Integer set should not contain element 0.", intSet.contains(0));
    assertFalse("Integer set should not contain element 5.", intSet.contains(5));
    assertFalse("Integer set should not contain element 10.", intSet.contains(10));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Aggregations

IntSet (com.b2international.collections.ints.IntSet)43 Test (org.junit.Test)38 IntIterator (com.b2international.collections.ints.IntIterator)4 PrimitiveSets (com.b2international.collections.PrimitiveSets)2 Comparator (java.util.Comparator)2 List (java.util.List)2 LongSet (com.b2international.collections.longs.LongSet)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 AbstractSet (java.util.AbstractSet)1 Iterator (java.util.Iterator)1 Objects (java.util.Objects)1