test.py 412 B

123456789101112131415
  1. #!/usr/bin/env python3
  2. from rfc1982_serial_number import Serial, step, show
  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. show(step(i1, i2))