def test_remove(self): l = OrderedList() l.add('test') l.add(1) l.add('ABC') l.remove(1) self.assertEqual(l.toList(), ['ABC', 'test'])
def test_index(self): l = OrderedList() l.add('test') l.add(100) l.add('ABC') self.assertEqual(l.index(100), 1) self.assertEqual(l.index(2), -1)
def test_search(self): l = OrderedList() l.add('test') l.add(1) l.add('ABC') self.assertEqual(l.search('ABC'), True) self.assertEqual(l.search(2), False)
def test_pop(self): l = OrderedList() l.add('test') l.add(100) l.add('ABC') self.assertEqual(l.pop(-1), None) self.assertEqual(l.pop(5), None) self.assertEqual(l.pop(0), 'test')
def test_size(self): mylist = OrderedList() self.assertEquals(mylist.size(), 0) mylist.add(1) self.assertEquals(mylist.size(), 1) mylist.add(2) self.assertEquals(mylist.size(), 2)
def test_pop(self): mylist = OrderedList() mylist.add(1) mylist.add(2) mylist.add(3) self.assertEqual(mylist.pop(), 3) self.assertEqual(mylist.size(), 2)
def setUp(self): self.mylist = OrderedList() self.mylist.add(12) self.mylist.add(22) self.mylist.add(9) self.mylist.add(89) self.mylist.add(71) self.mylist.add(16)
def test_index(self): mylist = OrderedList() mylist.add(1) mylist.add(2) mylist.add(3) self.assertEqual(mylist.index(3), 3)
def test_search_item(self): mylist = OrderedList() mylist.add(1) mylist.add(2) mylist.add(3) self.assertEqual(mylist.search(3), True) self.assertEqual(mylist.search(4), False)
def test_add_items(self): mylist = OrderedList() mylist.add(3) mylist.add(2) mylist.add(1) self.assertEqual(mylist.head.getData(), 1) self.assertEqual(mylist.head.getNext().getData(), 2) self.assertEqual(mylist.head.getNext().getNext().getData(), 3)
def test_isEmpty(self): l = OrderedList() l.add('test') l.add(100) l.add('ABC') self.assertEqual(l.isEmpty(), False) l.remove('test') l.remove(100) l.remove('ABC') self.assertEqual(l.isEmpty(), True)
def test_length(self): l = OrderedList() l.add('test') l.add(100) l.add('ABC') self.assertEqual(l.length(), 3)
def test_add(self): l = OrderedList() l.add('test') l.add(1) l.add('ABC') self.assertEqual(l.toList(), ['ABC', 1, 'test'])
class OrderedListTestCase(unittest.TestCase): def setUp(self): self.mylist = OrderedList() self.mylist.add(12) self.mylist.add(22) self.mylist.add(9) self.mylist.add(89) self.mylist.add(71) self.mylist.add(16) def test_length(self): self.assertEqual(self.mylist.length(), 6) def test_search(self): self.assertEqual(self.mylist.search(89), True) self.assertEqual(self.mylist.search(8), False) def test_remove(self): self.mylist.remove(12) self.mylist.remove(11) self.assertEqual(self.mylist.search(12), False) self.assertEqual(self.mylist.search(11), False) self.assertEqual(self.mylist.length(), 5) def test_toList(self): self.assertEqual(self.mylist.toList(), [9, 12, 16, 22, 71, 89])
def test_remove(self): mylist = OrderedList() mylist.add(1) mylist.remove(1) self.assertEqual(mylist.isEmpty(), True)
def test_isempty(self): mylist = OrderedList() self.assertEqual(mylist.isEmpty(), True) mylist.add(1) self.assertEqual(mylist.isEmpty(), False)