fast on list, add test script

This commit is contained in:
Kyryl Melekhin
2021-07-13 03:41:53 +00:00
parent c37ed995e3
commit 3d4b823a30
2 changed files with 42 additions and 41 deletions

21
test.sh Executable file
View File

@@ -0,0 +1,21 @@
regex="abc cde (a|b)|c"
input="abcdef abcdef abc"
expect="(0,3) (2,5) (0,1)(0,1)"
c=1
echo "$regex" | tr ' ' '\n' | while read re; do
inp=$(echo $input | awk -v c=$c '{print $c}')
exp=$(echo $expect | awk -v c=$c '{print $c}')
var=$(echo $(./a.out "$re" "$inp" | awk 'END{print}'))
if [ ! "$exp" = "$var" ]; then
echo "fail test$c regex:$re input:$inp expect:$exp output:$var"
exit 1
fi
c=$((c+1))
done