sh_quote/test_sh_quote

21 lines
404 B
Plaintext
Raw Normal View History

2022-09-11 16:51:37 +02:00
#!/bin/sh
PROG=${1:-./sh_quote}
run_test() {
r=$($PROG "$2"|sed 's/^ *//;s/ *$//')
2022-09-21 14:14:45 +02:00
if test "$r" = "$3"; then
2022-09-11 16:51:37 +02:00
echo PASS "$1"
else
echo FAIL "$1"
printf "Expected: %s\nGot: %s\n" "$3" "$r"
fi
}
run_test empty "" "''"
run_test whitespace "Foo Bar" "'Foo Bar'"
run_test quote "Foo'Bar" "'Foo'\''Bar'"
run_test newline "Foo
Bar" "'Foo
Bar'"
run_test trailing_space "Foobar " "'Foobar '"