Created
April 20, 2011 17:06
-
-
Save qwertme/931961 to your computer and use it in GitHub Desktop.
Bash assertions
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
ASSERT_COUNTER=0 | |
ASSERT_FAIL_COUNTER=0 | |
assert_equal() { | |
let ASSERT_COUNTER=ASSERT_COUNTER+1 | |
if [ "$1" != "$2" ]; then | |
let ASSERT_FAIL_COUNTER=ASSERT_FAIL_COUNTER+1 | |
echo "Expecting '$1' got '$2'" | |
fi | |
} | |
assert_file_line() { | |
assert_equal "$1" "`head -$2 $3 | tail -1`" | |
} | |
print_results() { | |
echo "Ran $ASSERT_COUNTER tests with $ASSERT_FAIL_COUNTER failures" | |
if [ "$ASSERT_FAIL_COUNTER" -ne "0" ]; then | |
echo "UNIT TESTS FAILED" | |
else | |
echo "UNIT TESTS PASSED" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment