[PATCH 3/5] completion: add tests for the __gitcomp_nl() completion helper function
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- Sep 28, 2012, 10:09 UTC
- Message-ID
- <1348826975-2225-3-git-send-email-szeder@ira.uka.de>
- In-Reply-To
- <1348826975-2225-1-git-send-email-szeder@ira.uka.de>
Test __gitcomp_nl()'s basic functionality, i.e. that trailing space, prefix, and suffix are added correctly.
Signed-off-by: SZEDER Gábor <szeder@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