Exemplo n.º 1
0
    def hybridencode(self, input, want):

        # Check the C implementation if it's in use
        got = store._pathencode(input)
        self.assertEqual(want, got)
        # Check the reference implementation in Python
        refgot = store._hybridencode(input, True)
        self.assertEqual(want, refgot)
Exemplo n.º 2
0
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
Exemplo n.º 3
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()
Exemplo n.º 4
0
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
Exemplo n.º 5
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