aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100644
index 0000000..d0e5d48
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,23 @@
+import pytest
+from fuzzycat.utils import slugify_string, cut
+
+
+def test_slugify_string():
+ assert slugify_string("") == ""
+ assert slugify_string("X") == "x"
+ assert slugify_string("Xx") == "xx"
+ assert slugify_string("Xx x") == "xx x"
+ assert slugify_string("Xx x x") == "xx x x"
+ assert slugify_string("Xx?x x") == "xxx x"
+ assert slugify_string("Xx? ?x x") == "xx x x"
+ assert slugify_string("Xx?_?x--x") == "xxxx"
+ assert slugify_string("=?++*") == ""
+
+
+def test_cut():
+ assert cut()("a b") == "a"
+ assert cut(1)("a b") == "b"
+ assert cut(2, sep=',')("a,b,c") == "c"
+ assert cut(3, sep=',')("a,b,c") == ""
+ with pytest.raises(ValueError):
+ cut(3, sep=',', ignore_missing_column=False)("a,b,c") == ""