def test_count(self): r = Range(1, 10) self.assertEqual(r.count(9), 1) self.assertEqual(r.count(10), 0) r = Range(1, 10, 3) self.assertEqual(r.count(7), 1) self.assertEqual(r.count(9), 0) r = Range(-5, 5) self.assertEqual(r.count(4), 1) self.assertEqual(r.count(5), 0) r = Range(-5, 5, 3) self.assertEqual(r.count(4), 1) self.assertEqual(r.count(5), 0) r = Range(5, -5, -1) self.assertEqual(r.count(-4), 1) self.assertEqual(r.count(-5), 0) r = Range(5, -5, -3) self.assertEqual(r.count(-4), 1) self.assertEqual(r.count(-5), 0) r = Range(-1, -10, -1) self.assertEqual(r.count(-9), 1) self.assertEqual(r.count(-10), 0) r = Range(-1, -10, -3) self.assertEqual(r.count(-7), 1) self.assertEqual(r.count(-9), 0)
def test_large_nums(self): import sys ln = sys.maxsize + 1 r = Range(ln, 3 * ln, 1) o = range(ln, 3 * ln, 1) self.assertEqual(r._len, 2 * ln) self.assertEqual(r[0], o[0]) self.assertEqual(r[-1], r[-1]) self.assertIn(2 * ln, r) self.assertEqual(r.count(2 * ln), 1) self.assertEqual(r.index(2 * ln), o.index(2 * ln))