|
1 | 1 | import unittest |
2 | | -from . import str_to_int |
| 2 | +from . import str_to_int, str_to_int_v2 |
3 | 3 |
|
4 | 4 |
|
5 | 5 | class StrToIntTestCases(unittest.TestCase): |
@@ -53,5 +53,56 @@ def test_7(self): |
53 | 53 | self.assertEqual(expected, actual) |
54 | 54 |
|
55 | 55 |
|
| 56 | +class StrToIntV2TestCases(unittest.TestCase): |
| 57 | + def test_1(self): |
| 58 | + """should convert '123' to 123""" |
| 59 | + input_str = "123" |
| 60 | + expected = 123 |
| 61 | + actual = str_to_int_v2(input_str) |
| 62 | + self.assertEqual(expected, actual) |
| 63 | + |
| 64 | + def test_2(self): |
| 65 | + """should convert '-12332' to -12332""" |
| 66 | + input_str = "-12332" |
| 67 | + expected = -12332 |
| 68 | + actual = str_to_int_v2(input_str) |
| 69 | + self.assertEqual(expected, actual) |
| 70 | + |
| 71 | + def test_3(self): |
| 72 | + """should convert '554' to 554""" |
| 73 | + input_str = "554" |
| 74 | + expected = 554 |
| 75 | + actual = str_to_int_v2(input_str) |
| 76 | + self.assertEqual(expected, actual) |
| 77 | + |
| 78 | + def test_4(self): |
| 79 | + """should convert '0' to 0""" |
| 80 | + input_str = "0" |
| 81 | + expected = 0 |
| 82 | + actual = str_to_int_v2(input_str) |
| 83 | + self.assertEqual(expected, actual) |
| 84 | + |
| 85 | + def test_5(self): |
| 86 | + """should convert '-1293' to -1293""" |
| 87 | + input_str = "-1293" |
| 88 | + expected = -1293 |
| 89 | + actual = str_to_int_v2(input_str) |
| 90 | + self.assertEqual(expected, actual) |
| 91 | + |
| 92 | + def test_6(self): |
| 93 | + """should convert '529' to 529""" |
| 94 | + input_str = "529" |
| 95 | + expected = 529 |
| 96 | + actual = str_to_int_v2(input_str) |
| 97 | + self.assertEqual(expected, actual) |
| 98 | + |
| 99 | + def test_7(self): |
| 100 | + """should convert '-999' to -999""" |
| 101 | + input_str = "-999" |
| 102 | + expected = -999 |
| 103 | + actual = str_to_int_v2(input_str) |
| 104 | + self.assertEqual(expected, actual) |
| 105 | + |
| 106 | + |
56 | 107 | if __name__ == '__main__': |
57 | 108 | unittest.main() |
0 commit comments