コード例 #1
0
ファイル: ms_test.py プロジェクト: imclab/Coding4Interviews
    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))
コード例 #2
0
ファイル: ms_test.py プロジェクト: imclab/Coding4Interviews
    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))
コード例 #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))
コード例 #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))