2020-07-15 09:34:08 +08:00
|
|
|
import unittest
|
2017-03-28 17:14:21 +08:00
|
|
|
|
|
|
|
|
2020-07-15 09:34:08 +08:00
|
|
|
class TestSolution(unittest.TestCase):
|
2017-03-28 17:14:21 +08:00
|
|
|
|
|
|
|
def test_can_win_nim(self):
|
|
|
|
solution = Solution()
|
2020-07-15 09:34:08 +08:00
|
|
|
self.assertRaises(TypeError, solution.can_win_nim, None)
|
|
|
|
self.assertEqual(solution.can_win_nim(1), True)
|
|
|
|
self.assertEqual(solution.can_win_nim(2), True)
|
|
|
|
self.assertEqual(solution.can_win_nim(3), True)
|
|
|
|
self.assertEqual(solution.can_win_nim(4), False)
|
|
|
|
self.assertEqual(solution.can_win_nim(7), True)
|
|
|
|
self.assertEqual(solution.can_win_nim(40), False)
|
2017-03-28 17:14:21 +08:00
|
|
|
print('Success: test_can_win_nim')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestSolution()
|
|
|
|
test.test_can_win_nim()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-15 09:34:08 +08:00
|
|
|
main()
|