git » libfiu » commit 5c20f63

tests: Add a wildcards test

author Alberto Bertogli
2013-10-23 03:17:46 UTC
committer Alberto Bertogli
2013-10-29 02:12:13 UTC
parent 59ab15c739bce5f9563d8250849c588764aef453

tests: Add a wildcards test

This patch adds a few tests for the wildcard matching.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

tests/test-wildcards.py +44 -0

diff --git a/tests/test-wildcards.py b/tests/test-wildcards.py
new file mode 100644
index 0000000..6603299
--- /dev/null
+++ b/tests/test-wildcards.py
@@ -0,0 +1,44 @@
+"""
+Test the behaviour of the wildcard failure points.
+"""
+
+import fiu
+
+fiu.enable("a:b:c")
+assert fiu.fail("a:b:c")
+
+fiu.enable("a:b:*")
+assert fiu.fail("a:b:c")
+assert fiu.fail("a:b:x")
+assert fiu.fail("a:b:c:d")
+
+fiu.enable("a:b:c:d")
+assert fiu.fail("a:b:c:d")
+
+fiu.disable("a:b:c")
+assert fiu.fail("a:b:c")
+
+fiu.disable("a:b:*")
+assert not fiu.fail("a:b:c")
+assert not fiu.fail("a:b:x")
+assert fiu.fail("a:b:c:d")
+
+fiu.disable("a:b:c:d")
+assert not fiu.fail("a:b:c:d")
+
+
+s = "x"
+for i in range(200):
+    fiu.enable(s + "/*")
+    s += "/x"
+
+s = "x"
+for i in range(200):
+    assert fiu.fail(s + '/asdf')
+    fiu.disable(s + "/*")
+    s += "/x"
+
+fiu.enable("*")
+assert fiu.fail("asdf")
+fiu.disable("*")
+assert not fiu.fail("asdf")