class InsertInEmptyArrayTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()

    def test(self):
        self.assertEqual(0, self.da.count)
        self.assertEqual(0, len(self.da))

        self.da.insert(0, 1)

        self.assertEqual(1, self.da.count)
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(1, self.da[0])
class DeleteWithModifyCapacityTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 18):
            self.da.append(i)

    def test(self):
        self.assertEqual(32, self.da.capacity)
        self.assertEqual(17, self.da.count)

        self.da.delete(15)
        self.da.delete(14)

        self.assertEqual(32, self.da.capacity)
        self.assertEqual(15, self.da.count)
class DeleteMultipleTimesFromArray(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(32):
            self.da.append(i)

    def test(self):
        self.assertEqual(32, self.da.capacity)
        self.assertEqual(32, self.da.count)

        for i in reversed(range(len(self.da))):
            self.da.delete(i)

        self.assertEqual(0, self.da.count)
        self.assertEqual(16, self.da.capacity)
class DeleteFromStartTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 17):
            self.da.append(i)

    def test(self):
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)

        self.da.delete(0)

        self.assertEqual(16, self.da.capacity)
        self.assertEqual(15, self.da.count)
        self.assertEqual(2, self.da[0])
class InsertMultipleTimesTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 17):
            self.da.append(i)

    def test(self):
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)

        for i in range(16, 21):
            self.da.insert(i, i + 1)

        self.assertEqual(32, self.da.capacity)
        self.assertEqual(21, self.da.count)
        self.assertEqual(21, self.da[20])
class InsertAtStartTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 20):
            self.da.append(i)

    def test(self):
        self.assertEqual(32, self.da.capacity)
        self.assertEqual(19, self.da.count)

        self.da.insert(0, 21)

        self.assertEqual(21, self.da[0])
        self.assertEqual(1, self.da[1])
        self.assertEqual(20, len(self.da))
        self.assertEqual(32, self.da.capacity)
class InsertWithCapacityModifyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(32):
            self.da.append(i)

    def test(self):
        self.assertEqual(32, self.da.capacity)
        self.assertEqual(32, self.da.count)

        self.da.insert(16, 100)
        self.da.insert(33, 200)

        self.assertEqual(64, self.da.capacity)
        self.assertEqual(34, self.da.count)
        self.assertEqual(200, self.da[33])
class InsertAtEndTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 17):
            self.da.append(i)

    def test(self):
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)
        self.assertEqual(16, len(self.da))
        self.assertEqual(16, self.da[15])

        self.da.insert(16, 17)

        self.assertEqual(17, self.da[16])
        self.assertEqual(32, self.da.capacity)
        self.assertEqual(17, self.da.count)
class InsertAtMiddleTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 5):
            self.da.append(i)

    def test(self):
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(4, self.da.count)

        self.da.insert(2, 100)

        self.assertEqual(100, self.da[2])
        self.assertEqual(2, self.da[1])
        self.assertEqual(3, self.da[3])
        self.assertEqual(5, len(self.da))
        self.assertEqual(16, self.da.capacity)
class InsertAtBadPositionTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.da = DynArray()
        for i in range(1, 17):
            self.da.append(i)

    def test_more(self):
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)

        self.assertRaises(IndexError, self.da.insert, 17, 100)
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)

    def test_less(self):
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)

        self.assertRaises(IndexError, self.da.insert, -1, 100)
        self.assertEqual(16, self.da.capacity)
        self.assertEqual(16, self.da.count)
 def setUp(self) -> None:
     self.da = DynArray()
     for i in range(1, 17):
         self.da.append(i)
 def setUp(self) -> None:
     self.da = DynArray()
 def setUp(self):
     self.da = DynArray()
     self.da.append(15)
     self.da.append(38)
     self.da.append(73)
     self.da.append(24)
class TestDynArray(unittest.TestCase):
    def setUp(self):
        self.da = DynArray()
        self.da.append(15)
        self.da.append(38)
        self.da.append(73)
        self.da.append(24)

    def test_insert_1(self):
        self.da.insert(1, 120)
        self.arr = []
        for i in range(len(self.da)):
            self.arr.append(self.da[i])
        self.assertEqual(self.arr, [15, 120, 38, 73, 24])

    def test_insert_2(self):
        self.da.append(0)
        self.da.append(1)
        self.da.append(2)
        self.da.append(3)
        self.da.append(4)
        self.da.append(5)
        self.da.append(6)
        self.da.append(7)
        self.da.append(8)
        self.da.append(9)
        self.da.append(10)
        self.da.append(11)

        self.da.insert(15, 120)
        self.arr = []
        for i in range(len(self.da)):
            self.arr.append(self.da[i])
        self.assertEqual(
            self.arr,
            [15, 38, 73, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 120, 11])

    def test_delete(self):
        self.da.delete(1)
        self.arr = []
        for i in range(len(self.da)):
            self.arr.append(self.da[i])
        self.assertEqual(self.arr, [15, 73, 24])