Test __gitcomp_nl()'s basic functionality, i.e. that trailing space,
prefix, and suffix are added correctly.

Signed-off-by: SZEDER Gábor <sze...@ira.uka.de>
---
 t/t9902-completion.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index f5e68834..01f33220 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -146,6 +146,53 @@ test_expect_success '__gitcomp - suffix' '
        test_cmp expected out
 '
 
+test_expect_success '__gitcomp_nl - trailing space' '
+       sed -e "s/Z$//" >expected <<-\EOF &&
+       maint Z
+       master Z
+       EOF
+       (
+               local -a COMPREPLY &&
+               cur="m" &&
+               __gitcomp_nl "maint${newline}master${newline}pu" &&
+               IFS="$newline" &&
+               echo "${COMPREPLY[*]}" > out
+       ) &&
+       test_cmp expected out
+'
+
+test_expect_success '__gitcomp_nl - prefix' '
+       sed -e "s/Z$//" >expected <<-\EOF &&
+       --fixup=maint Z
+       --fixup=master Z
+       EOF
+       (
+               local -a COMPREPLY &&
+               cur="--fixup=m" &&
+               __gitcomp_nl "maint${newline}master${newline}next${newline}pu"\
+                               "--fixup=" "m" &&
+               IFS="$newline" &&
+               echo "${COMPREPLY[*]}" > out
+       ) &&
+       test_cmp expected out
+'
+
+test_expect_success '__gitcomp_nl - suffix' '
+       sed -e "s/Z$//" >expected <<-\EOF &&
+       branch.master.Z
+       branch.maint.Z
+       EOF
+       (
+               local -a COMPREPLY &&
+               cur="branch.ma" &&
+               __gitcomp_nl "master${newline}maint${newline}next${newline}pu"\
+                               "branch." "ma" "." &&
+               IFS="$newline" &&
+               echo "${COMPREPLY[*]}" > out
+       ) &&
+       test_cmp expected out
+'
+
 test_expect_success 'basic' '
        run_completion git "" &&
        # built-in
-- 
1.7.12.1.438.g7dfa67b

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to