예제 #1
0
class TestSingleNumber(unittest.TestCase):

    def setUp(self):
        self.sn = SingleNumber()

    def test_single_number(self):
        self.assertEqual(1, self.sn.singleNumber([2, 2, 1]))
        self.assertEqual(4, self.sn.singleNumber([4, 1, 2, 1, 2]))
    def test_singleNumber(self):
        """
        Given nums = [4,1,2,1,2]
        return 4.
        """
        nums = [4,1,2,1,2]
        expected = 4

        sol = Solution()
        result = sol.singleNumber(nums)
        self.assertEqual(int(result), expected)