equal
deleted
inserted
replaced
10 import binascii, itertools, math, os, random, sys, time |
10 import binascii, itertools, math, os, random, sys, time |
11 import collections |
11 import collections |
12 |
12 |
13 if sys.version_info[:2] < (2, 6): |
13 if sys.version_info[:2] < (2, 6): |
14 sys.exit(0) |
14 sys.exit(0) |
15 |
|
16 def hybridencode(path): |
|
17 return store._hybridencode(path, True) |
|
18 |
15 |
19 validchars = set(map(chr, range(0, 256))) |
16 validchars = set(map(chr, range(0, 256))) |
20 alphanum = range(ord('A'), ord('Z')) |
17 alphanum = range(ord('A'), ord('Z')) |
21 |
18 |
22 for c in '\0/': |
19 for c in '\0/': |
155 yield makepath(rng, x, y) |
152 yield makepath(rng, x, y) |
156 |
153 |
157 def runtests(rng, seed, count): |
154 def runtests(rng, seed, count): |
158 nerrs = 0 |
155 nerrs = 0 |
159 for p in genpath(rng, count): |
156 for p in genpath(rng, count): |
160 hybridencode(p) |
157 h = store._dothybridencode(p) # uses C implementation, if available |
|
158 r = store._hybridencode(p, True) # reference implementation in Python |
|
159 if h != r: |
|
160 if nerrs == 0: |
|
161 print >> sys.stderr, 'seed:', hex(seed)[:-1] |
|
162 print >> sys.stderr, "\np: '%s'" % p.encode("string_escape") |
|
163 print >> sys.stderr, "h: '%s'" % h.encode("string_escape") |
|
164 print >> sys.stderr, "r: '%s'" % r.encode("string_escape") |
|
165 nerrs += 1 |
161 return nerrs |
166 return nerrs |
162 |
167 |
163 def main(): |
168 def main(): |
164 import getopt |
169 import getopt |
165 |
170 |