Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enh] new testcases, better notifications

  • Loading branch information...
commit c0ce2709241bcd78abb207593c4add9d2bec3e78 1 parent 175226e
@asciimoo authored
Showing with 28 additions and 6 deletions.
  1. +28 −6 tests.py
View
34 tests.py
@@ -18,21 +18,43 @@
BIGS = ['^a*$'
,'^[a-zA-Z]+$'
,'^(foo){3,}$'
+ ,'([^/]+)(.*)'
+ ,'[^/]+(.*)'
+ ,'([^/]+).*'
+ ,'([^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]|asdf)+'
]
def gen_test():
for regex, result in RS.items():
- assert list(generate(regex)) == result
+ try:
+ assert list(generate(regex)) == result
+ except:
+ print '[E] Assertion error! "%s"\n\t%r != %r' % (regex, list(generate(regex)), result)
def count_test():
for regex, result in RS.items():
- assert count(regex) == len(result)
+ c = count(regex)
+ l = len(result)
+ try:
+ assert c == l
+ except:
+ print '[E] Assertion error! "%s"\n\t%d != %d' % (regex, c, l)
-def getone_test():
+def getone_test(tries):
for regex,_ in RS.items():
- assert match(regex, getone(regex))
+ for _ in range(tries):
+ s = getone(regex)
+ try:
+ assert match(regex, s)
+ except:
+ print '[E] Assertion error! "%s"\n\t%s not match' % (regex, s)
for regex in BIGS:
- assert match(regex, getone(regex))
+ for _ in range(tries):
+ s = getone(regex)
+ try:
+ assert match(regex, s)
+ except:
+ print '[E] Assertion error! "%s"\n\t%s not match' % (regex, s)
if __name__ == '__main__':
@@ -40,5 +62,5 @@ def getone_test():
print('[+] generation test passed')
count_test()
print('[+] length test passed')
- getone_test()
+ getone_test(200)
print('[+] random generation test passed')

0 comments on commit c0ce270

Please sign in to comment.
Something went wrong with that request. Please try again.