f2380eef05
git-subtree-dir: lcthw-remnants git-subtree-mainline:4107485591
git-subtree-split:e172f73c82
57 lines
1.0 KiB
Bash
Executable File
57 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
EXIT_CODE=0
|
|
|
|
run_test()
|
|
{
|
|
echo -n " $1"
|
|
out_tmp="$(mktemp)"
|
|
./ex24_iofunctions$1 < "$2" > "$out_tmp"
|
|
diff_out="$(mktemp)"
|
|
diff -u "$3" "$out_tmp" > "$diff_out"
|
|
diff_count="$(cat "$diff_out" | wc -l)"
|
|
if [[ "$?" == "0" ]] && [[ "$diff_count" == "0" ]]
|
|
then
|
|
echo " ... OK"
|
|
else
|
|
echo " ... FAIL"
|
|
echo " diff count => $diff_count"
|
|
cat "$diff_out"
|
|
EXIT_CODE=1
|
|
fi
|
|
rm -f "$2" "$out_tmp" "$diff_out"
|
|
}
|
|
|
|
|
|
tmp_01="$(mktemp)"
|
|
cat > "$tmp_01" <<EOF
|
|
2 8 n
|
|
EOF
|
|
expected_01="$(mktemp)"
|
|
cat > "$expected_01" <<EOF
|
|
Reading from stdin: <a:number> <b:number> <c:letter>
|
|
> Read in: a=2 b=8 c=n
|
|
EOF
|
|
|
|
tmp_02="$(mktemp)"
|
|
tmp_02in="$(mktemp)"
|
|
cat > "$tmp_02in" <<EOF
|
|
1 4 a
|
|
EOF
|
|
cat > "$tmp_02" <<EOF
|
|
$tmp_02in
|
|
EOF
|
|
expected_02="$(mktemp)"
|
|
cat > "$expected_02" <<EOF
|
|
Provide filename from which to inputs
|
|
> Reading from file: <a:number> <b:number> <c:letter>
|
|
Read in: a=1 b=4 c=a
|
|
EOF
|
|
|
|
|
|
run_test '01' "$tmp_01" "$expected_01"
|
|
run_test '02' "$tmp_02" "$expected_02"
|
|
|
|
|
|
exit $EXIT_CODE
|