Files
indivisible-rs/test.sh

51 lines
720 B
Bash
Raw Normal View History

2022-03-01 18:42:10 +01:00
#!/bin/bash
2025-12-04 11:04:16 +01:00
DEBUG_BIN="./target/debug/indivisible"
RELEASE_BIN="./target/release/indivisible"
if [ -f "$DEBUG_BIN" ]
then
BINARY="$DEBUG_BIN"
elif [ -f "$RELEASE_BIN" ]
then
BINARY="$RELEASE_BIN"
else
>&2 echo "No valid binary found. Please compile the project."
exit 1
fi
tests=0
passed=0
((tests++))
echo -n "${tests}: Find 5th prime number..."
if [[ $("$BINARY" 5) == 11 ]]
2022-03-01 18:42:10 +01:00
then
echo " pass"
2025-12-04 11:04:16 +01:00
((passed++))
2022-03-01 18:42:10 +01:00
else
echo " FAIL"
fi
2025-12-04 11:04:16 +01:00
((tests++))
echo -n "${tests}: 11 is prime..."
if "$BINARY" -t 11
2022-03-01 18:42:10 +01:00
then
echo " pass"
2025-12-04 11:04:16 +01:00
((passed++))
2022-03-01 18:42:10 +01:00
else
echo " FAIL"
fi
2025-12-04 11:04:16 +01:00
((tests++))
echo -n "${tests}: 9 is not prime..."
if ! "$BINARY" -t 9
2022-03-01 18:42:10 +01:00
then
echo " pass"
2025-12-04 11:04:16 +01:00
((passed++))
2022-03-01 18:42:10 +01:00
else
echo " FAIL"
fi
2025-12-04 11:04:16 +01:00
echo "Results: $passed/$tests"