def show(s): # show test input print("A = '%s'" % s.encode("string_escape")) # show the result of the C implementation, if available h = store._pathencode(s) print("B = '%s'" % h.encode("string_escape")) # compare it with reference implementation in Python r = store._hybridencode(s, True) if h != r: print("R = '%s'" % r.encode("string_escape")) print()
def runtests(rng, seed, count): nerrs = 0 for p in genpath(rng, count): h = store._pathencode(p) # uses C implementation, if available r = store._hybridencode(p, True) # reference implementation in Python if h != r: if nerrs == 0: print("seed:", hex(seed)[:-1], file=sys.stderr) print("\np: '%s'" % p.encode("string_escape"), file=sys.stderr) print("h: '%s'" % h.encode("string_escape"), file=sys.stderr) print("r: '%s'" % r.encode("string_escape"), file=sys.stderr) nerrs += 1 return nerrs