summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHaidong Ji2019-01-02 16:09:25 -0600
committerHaidong Ji2019-01-02 16:09:25 -0600
commit374f0d359768aa2891b2a6dc24f195f0ec277ab2 (patch)
treefd09cb125e4e2be2472e1e66b1896aee56e82872 /tests
Check bracket done!
Strict TDD is not possible, at least the type I'm used to through Eclipse PyDev, where I write tests first, and rely on PyDev to generate files/function stubs. Bummer, but I decided to stick with PyCharm just to learn it.
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/check_bracketTest.py58
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/check_bracketTest.py b/tests/check_bracketTest.py
new file mode 100644
index 0000000..40f97d0
--- /dev/null
+++ b/tests/check_bracketTest.py
@@ -0,0 +1,58 @@
+import unittest
+
+from sources.check_bracket import check_bracket
+
+
+class MyTestCase(unittest.TestCase):
+
+ def test1(self):
+ exp = "[]"
+ self.assertEqual("Success", check_bracket(exp))
+
+ def test2(self):
+ exp = "{}[]"
+ self.assertEqual("Success", check_bracket(exp))
+
+ def test3(self):
+ exp = "[()]"
+ self.assertEqual("Success", check_bracket(exp))
+
+ def test4(self):
+ exp = "(())"
+ self.assertEqual("Success", check_bracket(exp))
+
+ def test5(self):
+ exp = "{[]}()"
+ self.assertEqual("Success", check_bracket(exp))
+
+ def test6(self):
+ exp = "{"
+ self.assertEqual(1, check_bracket(exp))
+
+ def test7(self):
+ exp = "{[}"
+ self.assertEqual(3, check_bracket(exp))
+
+ def test8(self):
+ exp = "foo(bar)"
+ self.assertEqual("Success", check_bracket(exp))
+
+ def test9(self):
+ exp = "foo(bar[i);"
+ self.assertEqual(10, check_bracket(exp))
+
+ def test10(self):
+ exp = "[](()"
+ self.assertEqual(3, check_bracket(exp))
+
+ def test11(self):
+ exp = "{[}haha"
+ self.assertEqual(3, check_bracket(exp))
+
+ def test12(self):
+ exp = "haha{[}"
+ self.assertEqual(7, check_bracket(exp))
+
+
+if __name__ == '__main__':
+ unittest.main()