summaryrefslogtreecommitdiff
path: root/tests/hash_chainsTest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hash_chainsTest.py')
-rw-r--r--tests/hash_chainsTest.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/hash_chainsTest.py b/tests/hash_chainsTest.py
new file mode 100644
index 0000000..5bdac8f
--- /dev/null
+++ b/tests/hash_chainsTest.py
@@ -0,0 +1,35 @@
+import unittest
+
+from sources.hash_chains import QueryProcessor, Query
+
+class MyTestCase(unittest.TestCase):
+ def test_something(self):
+ proc = QueryProcessor(5)
+ self.assertEqual(4, proc.hash_func('world'))
+ self.assertEqual(4, proc.hash_func('HellO'))
+ self.assertEqual(2, proc.hash_func('GooD'))
+ self.assertEqual(2, proc.hash_func('luck'))
+
+ def test_something1(self):
+ proc = QueryProcessor(3)
+ self.assertEqual(1, proc.hash_func('add'))
+ self.assertEqual(1, proc.hash_func('help'))
+ self.assertEqual(2, proc.hash_func('del'))
+
+ proc.elems = [[] for i in range(12)]
+ proc.process_query(Query(['check', 0]))
+ proc.process_query(Query(['find', 'help']))
+ proc.process_query(Query(['add', 'help']))
+ proc.process_query(Query(['add', 'del']))
+ proc.process_query(Query(['add', 'add']))
+ proc.process_query(Query(['find', 'add']))
+ proc.process_query(Query(['find', 'del']))
+ proc.process_query(Query(['del', 'del']))
+ proc.process_query(Query(['find', 'del']))
+ proc.process_query(Query(['check', 0]))
+ proc.process_query(Query(['check', 1]))
+ proc.process_query(Query(['check', 2]))
+
+
+if __name__ == '__main__':
+ unittest.main()