From f7d5f47a9b32d658fde2ff8d46a1f743eb72c8cb Mon Sep 17 00:00:00 2001 From: asciimoo Date: Wed, 4 Jul 2012 12:02:46 +0200 Subject: [PATCH] [enh] testcases added --- tests.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests.py diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..f8d9d41 --- /dev/null +++ b/tests.py @@ -0,0 +1,26 @@ + + +from exrex import generate, count + + +RS = {'[ab][cd]': ['ac', 'ad', 'bc', 'bd'] + ,'[12]{1,2}': ['1', '2', '11', '12', '21', '22'] + ,'((hai){2}|world)!': ['haihai!', 'world!'] + ,'[ab]{1,3}': ['a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', 'aab', 'aba', 'abb', 'baa', 'bab', 'bba', 'bbb'] + ,'\d': map(str, range(0, 10)) + } + +def gen_test(): + for regex, result in RS.items(): + assert list(generate(regex)) == result + +def count_test(): + for regex, result in RS.items(): + if not count(regex) == len(result): + print '[LENERR] "%s" - %d:%d' % (regex, count(regex), len(result)) + + +if __name__ == '__main__': + gen_test() + print '[!] generation test passed' + count_test()