summaryrefslogtreecommitdiff
path: root/tests/build_heapTest.py
blob: 3b934bf0e4ca388a6352bc380edcec8792e443d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import unittest

from sources.build_heap import get_swaps


class MyTestCase(unittest.TestCase):
    def test(self):
        data = [5, 4, 3, 2, 1]
        swaps = get_swaps(data)
        self.assertEqual(len(swaps), 3)
        self.assertEqual(1, swaps[0][0])
        self.assertEqual(4, swaps[0][1])
        self.assertEqual(0, swaps[1][0])
        self.assertEqual(1, swaps[1][1])
        self.assertEqual(1, swaps[2][0])
        self.assertEqual(3, swaps[2][1])

    def test1(self):
        data = [1, 2, 3, 4, 5]
        swaps = get_swaps(data)
        self.assertEqual(len(swaps), 0)


if __name__ == '__main__':
    unittest.main()