Example #1
0
    def test_sort_not_reversed(self):
        my_list = List()
        for i in range(19, -1, -1):
            my_list.append(i)

        comparison_list = List()
        for i in range(20):
            comparison_list.append(i)

        my_list.sort(False)
        self.assertEqual(my_list, comparison_list)
Example #2
0
    def test_resize_when_lower_than_one_eighth_cap_used(self):
        my_list = List()
        for i in range(21):
            my_list.append(i)

        for i in range(len(my_list), my_list.capacity // 8 - 2, -1):
            my_list.delete(i)

        self.assertLessEqual(my_list.capacity, my_list.BASE_SIZE)
Example #3
0
 def test_resize_when_exceed_max_cap(self):
     my_list = List()
     for i in range(21):
         my_list.append(i)
     self.assertGreater(my_list.capacity, my_list.BASE_SIZE)
Example #4
0
 def test_remove_invalid_item(self):
     my_list = List()
     my_list.append(1)
     self.assertFalse(my_list.remove("remove this"))
Example #5
0
 def test_delete_at_invalid_index(self):
     my_list = List()
     for i in range(10):
         my_list.append(i)
     self.assertFalse(my_list.delete(-11))
Example #6
0
 def test_insert_valid_index_full_list(self):
     my_list = List()
     my_list.append(1)
     self.assertTrue(my_list.insert(1, 2))
Example #7
0
 def test_remove_valid_item(self):
     my_list = List()
     my_list.append("remove this")
     self.assertTrue(my_list.remove("remove this"))
Example #8
0
 def test_insert_invalid_index_empty_list(self):
     my_list = List()
     self.assertFalse(my_list.insert(1, 1))
Example #9
0
 def test_insert_valid_index_empty_list(self):
     my_list = List()
     self.assertTrue(my_list.insert(0, 1))
Example #10
0
 def test_append_empty_list(self):
     my_list = List()
     my_list.append(2)
     self.assertEqual(my_list[0], 2)
Example #11
0
 def test_is_empty_false(self):
     my_list = List()
     my_list.append(1)
     self.assertFalse(my_list.is_empty())
Example #12
0
 def test_is_empty_true(self):
     my_list = List()
     self.assertTrue(my_list.is_empty())