def test_size(self): # default size arrayListEmpty = ArrayList() self.assertEquals(arrayListEmpty.size(), 0) # same element type arrayListContents = ArrayList([0, 1, 2]) self.assertEquals(arrayListContents.size(), 3)
def test_remove(self): testArrayList = ArrayList() # remove empty try: testArrayList.remove(1) print("test_remove: FAIL empty") except: print("test_remove: PASS empty") testArrayList.append(0) testArrayList.append(1) testArrayList.append(2) # remove out of bounds try: testArrayList.remove(5) print("test_remove: FAIL out of bounds") except: print("test_remove: PASS out of bounds") # remove at position testArrayList.remove(1) self.assertEquals(testArrayList.size(), 2) self.assertEquals(testArrayList.at(1), 2)
def test_append(self): testArrayList = ArrayList() # append testArrayList.append(0) self.assertEquals(testArrayList.size(), 1)
def test_clear(self): arrayList = ArrayList([1]) arrayList.clear() self.assertEquals(arrayList.size(), 0)