Many tests done, still more to come.
[szyfrow.git] / tests / test_languge_models.py
diff --git a/tests/test_languge_models.py b/tests/test_languge_models.py
new file mode 100644 (file)
index 0000000..0e00104
--- /dev/null
@@ -0,0 +1,18 @@
+import pytest
+import string 
+
+from szyfrow.support.language_models import *
+
+def test_transpositions_of():
+    assert transpositions_of('clever') == (0, 2, 1, 4, 3)
+    assert transpositions_of('fred') == (3, 2, 0, 1)
+    assert transpositions_of((3, 2, 0, 1)) == (3, 2, 0, 1)
+
+def test_ngrams():
+    assert ngrams(sanitise('the quick brown fox'), 2) == ['th', 'he', 'eq', 
+        'qu', 'ui', 'ic', 'ck', 'kb', 'br', 'ro', 'ow', 'wn', 
+        'nf', 'fo', 'ox']
+    assert ngrams(sanitise('the quick brown fox'), 4) == ['theq', 'hequ', 
+        'equi', 'quic', 'uick', 'ickb', 'ckbr', 'kbro', 'brow', 
+        'rown', 'ownf', 'wnfo', 'nfox']
+    
\ No newline at end of file