#!/usr/bin/env bash # Smoke tests for mini_calc. Exit 0 only when add/sub/mul/div are correct. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" CALC="$ROOT/calc" fail=0 expect() { local op=$1 a=$2 b=$3 want=$4 local got got="$("$CALC" "$op" "$a" "$b")" if [[ "$got" != "$want" ]]; then echo "FAIL: $op $a $b → got '$got' want '$want'" fail=1 else echo "ok: $op $a $b → $got" fi } expect add 2 3 5 expect sub 9 4 5 expect mul 3 4 12 expect div 8 2 4 if [[ "$fail" -ne 0 ]]; then echo "smoke: FAILED" exit 1 fi echo "smoke: PASSED" exit 0