'Check a randrange()-like function.'

def _check_randrange(self, func1, func2, func3, ptr, max_width):

    ints = []
    for i in range(10):
        ints.append(func1(500000000))
        ints.append(func2(5, 500000000))
        if (func3 is not None):
            ints.append(func3(5, 500000000, 3))
    self.assertEqual(len(ints), len(set(ints)), ints)
    if (sys.version_info >= (3,)):
        r = self._follow_cpython(ptr)
        widths = [w for w in [1, 5, 5000, ((2 ** 62) + (2 ** 61))] if (w < max_width)]
        for width in widths:
            self._check_dist(func1, r.randrange, [(width,)], niters=10)
            self._check_dist(func2, r.randrange, [((-2), (2 + width))], niters=10)
            if (func3 is not None):
                self.assertPreciseEqual(func3((-2), (2 + width), 6), r.randrange((-2), (2 + width), 6))
                self.assertPreciseEqual(func3((2 + width), 2, (-3)), r.randrange((2 + width), 2, (-3)))
    self.assertRaises(ValueError, func1, 0)
    self.assertRaises(ValueError, func1, (-5))
    self.assertRaises(ValueError, func2, 5, 5)
    self.assertRaises(ValueError, func2, 5, 2)
    if (func3 is not None):
        self.assertRaises(ValueError, func3, 5, 7, (-1))
        self.assertRaises(ValueError, func3, 7, 5, 1)
