12345678910111213141516171819202122232425262728 |
- #!/usr/bin/env python3
- from rfc1982_serial_number import Serial, find_intermediate
- from argparse import ArgumentParser
- from random import randint
- ap = ArgumentParser()
- ap.add_argument("iterations", type = int, default = 100000, nargs = "?")
- args = ap.parse_args()
- for test in range(args.iterations):
- i1 = Serial(randint(0, Serial.modulus - 1))
- i2 = Serial(randint(0, Serial.modulus - 1))
- assert i1 == i2 or \
- (i1 < i2 and not (i1 > i2)) or \
- (i1 > i2 and not (i1 < i2)) or \
- int(i1) ^ int(i2) == Serial.modulus >> 1
-
- step = [i1, i2]
- for wrap in find_intermediate(i1, i2):
- assert wrap > step[-2]
- step.insert(-1, wrap)
- for i in range(len(step) - 1):
- assert step[i] < step[i + 1]
- print(" => ".join(str(s) for s in step))
|