import student.TestCase; //------------------------------------------------------------------------- /** * Tests for the {@link ArraySet} class. * * @author Partner 1's name (pid) * @author Partner 2's name (pid) * @version (place the date here, in this format: yyyy.mm.dd) */ public class ArraySetTest extends TestCase { //~ Instance/static variables ............................................. private Set set1; private Set set2; //~ Constructor ........................................................... // ---------------------------------------------------------- /** * Create a new test class */ public ArraySetTest() { // The constructor is usually empty in unit tests, since it runs // once for the whole class, not once for each test method. // Per-test initialization should be placed in setUp() instead. } //~ Public methods ........................................................ // ---------------------------------------------------------- /** * Creates two brand new, empty sets for each test method. */ public void setUp() { set1 = new ArraySet(); set2 = new ArraySet(1); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#ArraySet()}. */ public void testArraySetConstructors() { // Check that a new set is empty assertTrue(set1.isEmpty()); assertTrue(set2.isEmpty()); // Initially, its size should be zero assertEquals(0, set1.size()); assertEquals(0, set2.size()); // It shouldn't contain our test item assertFalse(set1.contains("programming")); assertFalse(set2.contains("programming")); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#isEmpty()}. */ public void testIsEmpty() { set1.add("item"); assertFalse(set1.isEmpty()); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#size()}. */ public void testSize() { set1.add("item"); assertEquals(1, set1.size()); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#contains(Object)}. */ public void testContains() { fail("Not yet implemented"); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#add(Object)}. */ public void testAdd() { fail("Not yet implemented"); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#remove(Object)}. */ public void testRemove() { fail("Not yet implemented"); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#removeAny()}. */ public void testRemoveAny() { fail("Not yet implemented"); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#clear()}. */ public void testClear() { fail("Not yet implemented"); } // ---------------------------------------------------------- /** * Test method for {@link ArraySet#toString()}. */ public void testToString() { assertEquals("{}", set1.toString()); set1.add("item"); assertEquals("{item}", set1.toString()); set1.add("another"); assertEquals("{item, another}", set1.toString()); } }