Esempio n. 1
0
    def test_mergeSort(self):

        table = []
        sorter = TableSorter()
        self.assertEqual(None, sorter.mergeSort(table))

        table = [1]
        self.assertEqual(table, sorter.mergeSort(table))

        table = [1, 2]
        self.assertEqual(table, sorter.mergeSort(table))

        table = [13, 54, 2, 785, 32, 12]
        sorted_table = [2, 12, 13, 32, 54, 785]
        self.assertEqual(sorted_table, sorter.mergeSort(table))
Esempio n. 2
0
    def test_merge(self):
        table = [1, 2]
        t_1 = [1]
        t_2 = [2]

        sorter = TableSorter()
        self.assertEqual(table, sorter._merge(t_1, t_2))

        t_1 = [2]
        t_2 = [1]
        self.assertEqual(table, sorter._merge(t_1, t_2))

        table = [1, 2, 3, 5]
        t_1 = [2, 5]
        t_2 = [1, 3]
        self.assertEqual(table, sorter._merge(t_1, t_2))

        t_1 = [3, 5]
        t_2 = [1, 2]
        self.assertEqual(table, sorter._merge(t_1, t_2))
Esempio n. 3
0
    def test_mergeSort(self):

        table = []
        sorter = TableSorter()
        self.assertEqual(None, sorter.mergeSort(table))

        table = [1]
        self.assertEqual(table, sorter.mergeSort(table))

        table = [1, 2]
        self.assertEqual(table, sorter.mergeSort(table))

        table = [13, 54, 2, 785, 32, 12]
        sorted_table = [2, 12, 13, 32, 54, 785]
        self.assertEqual(sorted_table, sorter.mergeSort(table))
Esempio n. 4
0
    def test_merge(self):
        table = [1, 2]
        t_1 = [1]
        t_2 = [2]

        sorter = TableSorter()
        self.assertEqual(table, sorter._merge(t_1, t_2))

        t_1 = [2]
        t_2 = [1]
        self.assertEqual(table, sorter._merge(t_1, t_2))

        table = [1, 2, 3, 5]
        t_1 = [2, 5]
        t_2 = [1, 3]
        self.assertEqual(table, sorter._merge(t_1, t_2))

        t_1 = [3, 5]
        t_2 = [1, 2]
        self.assertEqual(table, sorter._merge(t_1, t_2))