add test, escape spaces in output
This commit is contained in:
26
test/01.sh
Executable file
26
test/01.sh
Executable 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
|
Reference in New Issue
Block a user