summaryrefslogtreecommitdiffstats
path: root/test/t/unit/test_unit_find_unique_completion_pair.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:14:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:14:42 +0000
commit0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3 (patch)
treeea0fe36eb5e6f40e0a1f765d44c4b0c0b2bfb089 /test/t/unit/test_unit_find_unique_completion_pair.py
parentInitial commit. (diff)
downloadbash-completion-426fcc495355916c13ae90c5ea36695615e342a5.tar.xz
bash-completion-426fcc495355916c13ae90c5ea36695615e342a5.zip
Adding upstream version 1:2.11.upstream/1%2.11upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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")