|
| 1 | +import unittest |
| 2 | +from . import non_constructible_change |
| 3 | + |
| 4 | + |
| 5 | +class NonConstructibleChangeTestCase(unittest.TestCase): |
| 6 | + def test_1(self): |
| 7 | + """should return 20 for input of [5, 7, 1, 1, 2, 3, 22]""" |
| 8 | + coins = [5, 7, 1, 1, 2, 3, 22] |
| 9 | + expected = 20 |
| 10 | + actual = non_constructible_change(coins) |
| 11 | + self.assertEqual(actual, expected) |
| 12 | + |
| 13 | + def test_2(self): |
| 14 | + """should return 6 for input of [1, 1, 1, 1, 1]""" |
| 15 | + coins = [1, 1, 1, 1, 1] |
| 16 | + expected = 6 |
| 17 | + actual = non_constructible_change(coins) |
| 18 | + self.assertEqual(actual, expected) |
| 19 | + |
| 20 | + def test_3(self): |
| 21 | + """should return 55 for input of [1, 5, 1, 1, 1, 10, 15, 20, 100]""" |
| 22 | + coins = [1, 5, 1, 1, 1, 10, 15, 20, 100] |
| 23 | + expected = 55 |
| 24 | + actual = non_constructible_change(coins) |
| 25 | + self.assertEqual(actual, expected) |
| 26 | + |
| 27 | + def test_4(self): |
| 28 | + """should return 3 for input of [6, 4, 5, 1, 1, 8, 9]""" |
| 29 | + coins = [6, 4, 5, 1, 1, 8, 9] |
| 30 | + expected = 3 |
| 31 | + actual = non_constructible_change(coins) |
| 32 | + self.assertEqual(actual, expected) |
| 33 | + |
| 34 | + def test_5(self): |
| 35 | + """should return 1 for input of []""" |
| 36 | + coins = [] |
| 37 | + expected = 1 |
| 38 | + actual = non_constructible_change(coins) |
| 39 | + self.assertEqual(actual, expected) |
| 40 | + |
| 41 | + def test_6(self): |
| 42 | + """should return 1 for input of [87]""" |
| 43 | + coins = [87] |
| 44 | + expected = 1 |
| 45 | + actual = non_constructible_change(coins) |
| 46 | + self.assertEqual(actual, expected) |
| 47 | + |
| 48 | + def test_7(self): |
| 49 | + """should return 32 for input of [5, 6, 1, 1, 2, 3, 4, 9]""" |
| 50 | + coins = [5, 6, 1, 1, 2, 3, 4, 9] |
| 51 | + expected = 32 |
| 52 | + actual = non_constructible_change(coins) |
| 53 | + self.assertEqual(actual, expected) |
| 54 | + |
| 55 | + def test_8(self): |
| 56 | + """should return 19 for input of [5, 6, 1, 1, 2, 3, 43]""" |
| 57 | + coins = [5, 6, 1, 1, 2, 3, 43] |
| 58 | + expected = 19 |
| 59 | + actual = non_constructible_change(coins) |
| 60 | + self.assertEqual(actual, expected) |
| 61 | + |
| 62 | + def test_9(self): |
| 63 | + """should return 3 for input of [1, 1]""" |
| 64 | + coins = [1, 1] |
| 65 | + expected = 3 |
| 66 | + actual = non_constructible_change(coins) |
| 67 | + self.assertEqual(actual, expected) |
| 68 | + |
| 69 | + def test_10(self): |
| 70 | + """should return 1 for input of [2]""" |
| 71 | + coins = [2] |
| 72 | + expected = 1 |
| 73 | + actual = non_constructible_change(coins) |
| 74 | + self.assertEqual(actual, expected) |
| 75 | + |
| 76 | + def test_11(self): |
| 77 | + """should return 2 for input of [1]""" |
| 78 | + coins = [1] |
| 79 | + expected = 2 |
| 80 | + actual = non_constructible_change(coins) |
| 81 | + self.assertEqual(actual, expected) |
| 82 | + |
| 83 | + def test_12(self): |
| 84 | + """should return 87 for input of [109, 2000, 8765, 19, 18, 17, 16, 8, 1, 1, 2, 4]""" |
| 85 | + coins = [109, 2000, 8765, 19, 18, 17, 16, 8, 1, 1, 2, 4] |
| 86 | + expected = 87 |
| 87 | + actual = non_constructible_change(coins) |
| 88 | + self.assertEqual(actual, expected) |
| 89 | + |
| 90 | + def test_13(self): |
| 91 | + """should return 29 for input of [1, 2, 3, 4, 5, 6, 7]""" |
| 92 | + coins = [1, 2, 3, 4, 5, 6, 7] |
| 93 | + expected = 29 |
| 94 | + actual = non_constructible_change(coins) |
| 95 | + self.assertEqual(actual, expected) |
| 96 | + |
| 97 | + def test_input_not_mutated(self): |
| 98 | + """should not mutate the input coins list""" |
| 99 | + coins = [5, 7, 1, 1, 2, 3, 22] |
| 100 | + snapshot = coins[:] |
| 101 | + _ = non_constructible_change(coins) |
| 102 | + self.assertEqual(coins, snapshot) |
| 103 | + |
| 104 | +if __name__ == '__main__': |
| 105 | + unittest.main() |
0 commit comments