You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
62 lines
1.6 KiB
2 years ago
|
import unittest
|
||
|
|
||
|
from merge.imlementation import merge, mergesort
|
||
|
|
||
|
from typing import List
|
||
|
|
||
|
|
||
|
class MergeTestCase(unittest.TestCase):
|
||
|
def test_merge_minimal(self):
|
||
|
self.assertEqual(
|
||
|
merge([], []),
|
||
|
[],
|
||
|
)
|
||
|
|
||
|
def test_merge_one(self):
|
||
|
self.assertEqual(merge([301], []), [301])
|
||
|
self.assertEqual(merge([-301], []), [-301])
|
||
|
self.assertEqual(merge([], [-31]), [-31])
|
||
|
self.assertEqual(merge([], [31]), [31])
|
||
|
|
||
|
def test_merge_two(self):
|
||
|
self.assertEqual(merge([301], [1]), [1, 301])
|
||
|
self.assertEqual(merge([1], [301]), [1, 301])
|
||
|
self.assertEqual(merge([-301, 1], []), [-301, 1])
|
||
|
self.assertEqual(merge([], [-301, 1]), [-301, 1])
|
||
|
|
||
|
def test_mergesort_minimal(self):
|
||
|
self.assertEqual(
|
||
|
mergesort([]),
|
||
|
[],
|
||
|
)
|
||
|
|
||
|
def test_mergesort_one(self):
|
||
|
self.assertEqual(mergesort([3]), [3])
|
||
|
self.assertEqual(mergesort([-3]), [-3])
|
||
|
|
||
|
def test_mergesort_two(self):
|
||
|
self.assertEqual(mergesort([1, 3]), [1, 3])
|
||
|
self.assertEqual(mergesort([3, 1]), [1, 3])
|
||
|
self.assertEqual(
|
||
|
mergesort([3, 3]),
|
||
|
[3, 3],
|
||
|
)
|
||
|
|
||
|
def test_small(self):
|
||
|
self.assertEqual(
|
||
|
mergesort([3, 3, 1, 2, 4, 6, 2, 4]),
|
||
|
[1, 2, 2, 3, 3, 4, 4, 6],
|
||
|
)
|
||
|
|
||
|
def test_small2(self):
|
||
|
self.assertEqual(
|
||
|
mergesort([3, -3, 1, 2, 4, -6, 2, 4]),
|
||
|
[-6, -3, 1, 2, 2, 3, 4, 4],
|
||
|
)
|
||
|
|
||
|
# def test_forbidden(self):
|
||
|
# self.assertEqual(
|
||
|
# mergesort(["a", "b", 3]),
|
||
|
# ["a", "b", 3],
|
||
|
# )
|