summaryrefslogtreecommitdiff
path: root/tests/common/fnv1a.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/fnv1a.py')
-rw-r--r--tests/common/fnv1a.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/common/fnv1a.py b/tests/common/fnv1a.py
new file mode 100644
index 0000000..2013afa
--- /dev/null
+++ b/tests/common/fnv1a.py
@@ -0,0 +1,25 @@
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.common import fnv1a
+
+
+class TestFnv1a(ChrysalideTestCase):
+ """TestCase for common.fnv1a*"""
+
+ def testFnv1aConstructor(self):
+ """Check that no constructor is available for the fnv1a class."""
+
+ with self.assertRaisesRegex(NotImplementedError, 'Chrysalide does not allow building this kind of object from Python'):
+ instance = fnv1a()
+
+
+ def testFnv1aSamples(self):
+ """Compute some Fnv1a hashs."""
+
+ # Test cases from http://isthe.com/chongo/src/fnv/test_fnv.c
+
+ val = fnv1a.hash('')
+ self.assertEqual(val, 0xcbf29ce484222325)
+
+ val = fnv1a.hash('chongo was here!\n')
+ self.assertEqual(val, 0x46810940eff5f915)