add test, escape spaces in output

This commit is contained in:
Tilman Kranz
2022-08-21 15:47:44 +02:00
parent 0ae62285f0
commit 69fc45061b
3 changed files with 35 additions and 7 deletions

26
test/01.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
dir=$(dirname "$(readlink -f "$0")")
trie="$dir/../trie.py"
read -r -d '' input <<EOF
a b x
a b c
a b c d
EOF
output=$(echo "$input" | "$trie")
# shellcheck disable=SC2086
result=$(eval 'for i in '$output' ; do echo "$i" ; done' | sort)
reference=$(echo "$input" | sort | uniq)
if test "$reference" = "$result" ; then
rv=0
else
printf 'ERROR: reference=\n%s\nresult=\n%s\n' "$reference" "$result"
rv=1
fi
exit $rv