trie/test/01.sh
2022-08-21 15:47:44 +02:00

27 lines
445 B
Bash
Executable File

#!/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