class TestReverse(unittest.TestCase): def setUp(self): self.r = Reverse() def test_reverse(self): self.assertEqual(321, self.r.reverse(123)) self.assertEqual(-321, self.r.reverse(-123)) self.assertEqual(21, self.r.reverse(120))
def test_reverse_Zero(self): sol = Solution() self.assertEqual(sol.reverse(0), 0)
def test_reverse_negNumWZero(self): sol = Solution() self.assertEqual(sol.reverse(-3210), -123)
def test_reverse_posNumWZero(self): sol = Solution() self.assertEqual(sol.reverse(120), 21)
def test_32bitsPos(self): self.assertEqual(Solution.reverse(b32), 0)
def test_randumNumber(self): self.assertEqual(0, Solution.reverse(1534236469))
def setUp(self): self.r = Reverse()
def test_reverse_posNum(self): sol = Solution() self.assertEqual(sol.reverse(123), 321)
def test_positive(self): self.assertEqual(321, Solution.reverse(123))
def test_32bitsLimNeg(self): self.assertEqual(0, Solution.reverse(b32 * -1))
def test_32bitsLimPost(self): self.assertEqual(0, Solution.reverse(b32 - 1))
def test_32bitsNeg(self): self.assertEqual(Solution.reverse((b32 * -1) - 1), 0)
def test_one_char(self): self.assertEqual(Solution().reverse('a'), 'a')
def test_no_char(self): self.assertEqual(Solution().reverse(''), '')
def test_normal(self): self.assertEqual(Solution().reverse('abc'), 'cba')
def test_reverse_largeNum(self): sol = Solution() self.assertEqual(sol.reverse(1234560709), 0)
def test_types(self): sol = Solution() self.assertRaises(TypeError, sol.reverse, '123') self.assertRaises(TypeError, sol.reverse, [123])
def test_negative(self): self.assertEqual(-321, Solution.reverse(-123))
def test_reverse_negNum(self): sol = Solution() self.assertEqual(sol.reverse(-654), -456)
def test_ReverseZero(self): self.assertEqual(21, Solution.reverse(120))