|
| 1 | +import unittest |
| 2 | +from . import sort_colors, sort_colors_v2 |
| 3 | + |
| 4 | + |
| 5 | +class SortColorsV2TestCase(unittest.TestCase): |
| 6 | + |
| 7 | + def test_1(self): |
| 8 | + """should sort colors = [1,0,2,1,2,2] to [0,1,1,2,2,2]""" |
| 9 | + colors = [1, 0, 2, 1, 2, 2] |
| 10 | + expected = [0, 1, 1, 2, 2, 2] |
| 11 | + actual = sort_colors_v2(colors) |
| 12 | + self.assertEqual(expected, actual) |
| 13 | + |
| 14 | + def test_2(self): |
| 15 | + """should sort colors = [0,1,1,2,0,2,0,2,1,2] to [0,0,0,1,1,1,2,2,2,2]""" |
| 16 | + colors = [0,1,1,2,0,2,0,2,1,2] |
| 17 | + expected = [0,0,0,1,1,1,2,2,2,2] |
| 18 | + actual = sort_colors_v2(colors) |
| 19 | + self.assertEqual(expected, actual) |
| 20 | + |
| 21 | + def test_3(self): |
| 22 | + """should sort colors = [0] to [0]""" |
| 23 | + colors = [0] |
| 24 | + expected = [0] |
| 25 | + actual = sort_colors_v2(colors) |
| 26 | + self.assertEqual(expected, actual) |
| 27 | + |
| 28 | + def test_4(self): |
| 29 | + """should sort colors = [0,1,0] to [0,0,1]""" |
| 30 | + colors = [0,1,0] |
| 31 | + expected = [0,0,1] |
| 32 | + actual = sort_colors_v2(colors) |
| 33 | + self.assertEqual(expected, actual) |
| 34 | + |
| 35 | + def test_5(self): |
| 36 | + """should sort colors = [1] to [1]""" |
| 37 | + colors = [1] |
| 38 | + expected = [1] |
| 39 | + actual = sort_colors_v2(colors) |
| 40 | + self.assertEqual(expected, actual) |
| 41 | + |
| 42 | + def test_6(self): |
| 43 | + """should sort colors = [2,2] to [2,2]""" |
| 44 | + colors = [2,2] |
| 45 | + expected = [2,2] |
| 46 | + actual = sort_colors_v2(colors) |
| 47 | + self.assertEqual(expected, actual) |
| 48 | + |
| 49 | + def test_7(self): |
| 50 | + """should sort colors = [1,1,0,2] to [0,1,1,2]""" |
| 51 | + colors = [1,1,0,2] |
| 52 | + expected = [0,1,1,2] |
| 53 | + actual = sort_colors_v2(colors) |
| 54 | + self.assertEqual(expected, actual) |
| 55 | + |
| 56 | + def test_8(self): |
| 57 | + """should sort colors = [2,1,1,0,0] to [0,0,1,1,2]""" |
| 58 | + colors = [2,1,1,0,0] |
| 59 | + expected = [0,0,1,1,2] |
| 60 | + actual = sort_colors_v2(colors) |
| 61 | + self.assertEqual(expected, actual) |
| 62 | + |
| 63 | + |
| 64 | +class SortColorsTestCase(unittest.TestCase): |
| 65 | + |
| 66 | + def test_1(self): |
| 67 | + """should sort colors = [1,0,2,1,2,2] to [0,1,1,2,2,2]""" |
| 68 | + colors = [1, 0, 2, 1, 2, 2] |
| 69 | + expected = [0, 1, 1, 2, 2, 2] |
| 70 | + actual = sort_colors(colors) |
| 71 | + self.assertEqual(expected, actual) |
| 72 | + |
| 73 | + def test_2(self): |
| 74 | + """should sort colors = [0,1,1,2,0,2,0,2,1,2] to [0,0,0,1,1,1,2,2,2,2]""" |
| 75 | + colors = [0,1,1,2,0,2,0,2,1,2] |
| 76 | + expected = [0,0,0,1,1,1,2,2,2,2] |
| 77 | + actual = sort_colors(colors) |
| 78 | + self.assertEqual(expected, actual) |
| 79 | + |
| 80 | + def test_3(self): |
| 81 | + """should sort colors = [0] to [0]""" |
| 82 | + colors = [0] |
| 83 | + expected = [0] |
| 84 | + actual = sort_colors(colors) |
| 85 | + self.assertEqual(expected, actual) |
| 86 | + |
| 87 | + def test_4(self): |
| 88 | + """should sort colors = [0,1,0] to [0,0,1]""" |
| 89 | + colors = [0,1,0] |
| 90 | + expected = [0,0,1] |
| 91 | + actual = sort_colors(colors) |
| 92 | + self.assertEqual(expected, actual) |
| 93 | + |
| 94 | + def test_5(self): |
| 95 | + """should sort colors = [1] to [1]""" |
| 96 | + colors = [1] |
| 97 | + expected = [1] |
| 98 | + actual = sort_colors(colors) |
| 99 | + self.assertEqual(expected, actual) |
| 100 | + |
| 101 | + def test_6(self): |
| 102 | + """should sort colors = [2,2] to [2,2]""" |
| 103 | + colors = [2,2] |
| 104 | + expected = [2,2] |
| 105 | + actual = sort_colors(colors) |
| 106 | + self.assertEqual(expected, actual) |
| 107 | + |
| 108 | + def test_7(self): |
| 109 | + """should sort colors = [1,1,0,2] to [0,1,1,2]""" |
| 110 | + colors = [1,1,0,2] |
| 111 | + expected = [0,1,1,2] |
| 112 | + actual = sort_colors(colors) |
| 113 | + self.assertEqual(expected, actual) |
| 114 | + |
| 115 | + def test_8(self): |
| 116 | + """should sort colors = [2,1,1,0,0] to [0,0,1,1,2]""" |
| 117 | + colors = [2,1,1,0,0] |
| 118 | + expected = [0,0,1,1,2] |
| 119 | + actual = sort_colors(colors) |
| 120 | + self.assertEqual(expected, actual) |
| 121 | + |
| 122 | +if __name__ == '__main__': |
| 123 | + unittest.main() |
0 commit comments