Example #1
0
 /** java.util.FastSet#add(java.lang.Object) */
 public void test_addLjava_lang_Object() {
   // Test for method boolean java.util.FastSet.add(java.lang.Object)
   int size = hs.size();
   hs.add(new Integer(8));
   assertTrue("Added element already contained by set", hs.size() == size);
   hs.add(new Integer(-9));
   assertTrue("Failed to increment set size after add", hs.size() == size + 1);
   assertTrue("Failed to add element to set", hs.contains(new Integer(-9)));
 }
Example #2
0
  /**
   * Sets up the fixture, for example, open a network connection. This method is called before a
   * test is executed.
   */
  protected void setUp() {
    objArray = new Object[1000];
    for (int i = 0; i < objArray.length; i++) {
      objArray[i] = new Integer(i);
    }

    hs = new SlimSet();
    for (int i = 0; i < objArray.length; i++) {
      hs.add(objArray[i]);
    }

    hs.add(null);
  }
Example #3
0
  /** java.util.FastSet#contains(java.lang.Object) */
  public void test_containsLjava_lang_Object() {
    // Test for method boolean java.util.FastSet.contains(java.lang.Object)
    assertTrue("Returned false for valid object", hs.contains(objArray[90]));
    assertTrue("Returned true for invalid Object", !hs.contains(new Object()));

    SlimSet s = new SlimSet();
    s.add(null);
    assertTrue("Cannot handle null", s.contains(null));
  }
Example #4
0
  /** java.util.FastSet#remove(java.lang.Object) */
  public void test_removeLjava_lang_Object() {
    // Test for method boolean java.util.FastSet.remove(java.lang.Object)
    int size = hs.size();
    hs.remove(new Integer(98));
    assertTrue("Failed to remove element", !hs.contains(new Integer(98)));
    assertTrue("Failed to decrement set size", hs.size() == size - 1);

    SlimSet s = new SlimSet();
    s.add(null);
    assertTrue("Cannot handle null", s.remove(null));
    assertFalse(hs.remove(new Integer(-98)));
  }
Example #5
0
  /** java.util.FastSet#iterator() */
  public void test_iterator() {
    // Test for method java.util.Iterator java.util.FastSet.iterator()
    Iterator i = hs.iterator();
    int x = 0;
    while (i.hasNext()) {
      assertTrue("Failed to iterate over all elements", hs.contains(i.next()));
      ++x;
    }
    assertTrue("Returned iteration of incorrect size", hs.size() == x);

    SlimSet s = new SlimSet();
    s.add(null);
    assertNull("Cannot handle null", s.iterator().next());
  }