Exemplo n.º 1
0
 def test_delete_last(self):
     a = DynArray()
     for i in range(16):
         a.append(i)
     a.delete(0)
     data = [a.capacity, a.__len__()]
     res =  [16, 15]
     self.assertEqual( data, res)
Exemplo n.º 2
0
 def test_delete_middle(self):
     a = DynArray()
     for i in range(10):
         a.append(i)
     a.delete(5)
     data = [a.capacity, a.__len__(), a.__getitem__(5)]
     res =  [16, 9, 6]
     self.assertEqual( data, res)
Exemplo n.º 3
0
 def test_delete_with_resize_1(self):
     a = DynArray()
     for i in range(17):
         a.append(i)
     a.delete(16)
     a.delete(15)
     data = [a.capacity, a.__len__(), a.__getitem__(14)]
     res =  [21, 15, 14]
     self.assertEqual( data, res)
Exemplo n.º 4
0
 def test_radom_delete(self):
     for i in range(1000):
         count_element = random.randint(1, 16)
         a = DynArray()
         a_list = []
         for i in range(count_element):
             a.append(i)
         delete_index = -1
         while not (-1 < delete_index < count_element):
             delete_index = random.randint(0, 16)
         a.delete(delete_index)
         #print(f'array size: {count_element}, insert index: {insert_index}')
         #for i in range(count_element - 1):
         #    a_list.append(a.__getitem__(i))
         #print(a_list)
         data = [a.__len__()]
         res = [count_element - 1,]
         self.assertEqual(data, res)