test1.py 553 B

1234567891011121314151617181920
  1. #!/usr/bin/env python3
  2. from rfc1982_serial_number import Serial, find_intermediate
  3. from random import randint
  4. for test in range(10000):
  5. i1 = Serial(randint(0, Serial.modulus - 1))
  6. i2 = Serial(randint(0, Serial.modulus - 1))
  7. assert i1 == i2 or \
  8. (i1 < i2 and not (i1 > i2)) or \
  9. (i1 > i2 and not (i1 < i2)) or \
  10. int(i1) ^ int(i2) == Serial.modulus >> 1
  11. step = [i1, i2]
  12. wrap = find_intermediate(i1, i2)
  13. if wrap is not None:
  14. step.insert(1, wrap)
  15. print(" => ".join(str(s) for s in step))