summaryrefslogtreecommitdiffstats
path: root/test/t/unit/test_unit_find_unique_completion_pair.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/t/unit/test_unit_find_unique_completion_pair.py')
-rw-r--r--test/t/unit/test_unit_find_unique_completion_pair.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/t/unit/test_unit_find_unique_completion_pair.py b/test/t/unit/test_unit_find_unique_completion_pair.py
new file mode 100644
index 0000000..25cf9d3
--- /dev/null
+++ b/test/t/unit/test_unit_find_unique_completion_pair.py
@@ -0,0 +1,55 @@
+import pytest
+
+from conftest import find_unique_completion_pair
+
+
+@pytest.mark.bashcomp(cmd=None)
+class TestUnitFindUniqueCompletionPair:
+ def _test(self, inp: str, exp: str) -> None:
+ res = find_unique_completion_pair(inp.split())
+ if exp:
+ part, cont = exp.split()
+ assert res == (part, part + cont)
+ else:
+ assert not exp
+
+ def test_1(self):
+ self._test("a", "")
+
+ def test_2(self):
+ self._test("ab", "a b")
+
+ def test_3(self):
+ self._test("ab ab ab", "a b")
+
+ def test_4(self):
+ self._test("a ab abcd abc", "")
+
+ def test_5(self):
+ self._test("user1 user2", "")
+
+ def test_6(self):
+ self._test("root username1 username2", "ro ot")
+
+ def test_7(self):
+ self._test("root username21 username2", "ro ot")
+
+ def test_8(self):
+ self._test(
+ "long_user_name lang_user_name long_usor_name", "lang_us er_name"
+ )
+
+ def test_9(self):
+ self._test(
+ "lang_user_name1 long_user_name lang_user_name long_usor_name",
+ "long_use r_name",
+ )
+
+ def test_10(self):
+ self._test("root username", "user name")
+
+ def test_11(self):
+ self._test("a aladin", "ala din")
+
+ def test_12(self):
+ self._test("ala aladin", "alad in")