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 >> sys.stderr, 'seed:', hex(seed)[:-1]
            print >> sys.stderr, "\np: '%s'" % p.encode("string_escape")
            print >> sys.stderr, "h: '%s'" % h.encode("string_escape")
            print >> sys.stderr, "r: '%s'" % r.encode("string_escape")
            nerrs += 1
    return nerrs
Example #2
0
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()