Created
April 10, 2021 06:11
-
-
Save halivert/f88485d4916deb4d5fc7948bfdc3edb8 to your computer and use it in GitHub Desktop.
Mini test framework (Tests programs with single input (stdin) and single output (stdout))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXEC="./$1" | |
function test() { | |
if [ "$1" $2 "$3" ]; then | |
echo -e "\e[32mPASS\e[0m" | |
else | |
echo -e "\e[31mNOT PASS - $1 $4 $3 \e[0m" | |
fi | |
} | |
function assertEquals() { | |
test $(echo $1 | $EXEC) = $2 "should be" | |
} | |
function assertDifferent() { | |
test $(echo $1 | $EXEC) != $2 "should not be" | |
} | |
# e.g. | |
# EXEC=fibonacci | |
# assertEquals 3 2 | |
# assertEquals 6 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment