2022-10-21 18:38:19 +00:00
|
|
|
# Always failing assertion with a message.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# fail "It should have been but it wasn't to be"
|
|
|
|
function fail() {
|
2024-04-21 15:54:59 +00:00
|
|
|
echo -e "$1"
|
2022-10-21 18:38:19 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
function assertStringEqual() {
|
2022-10-21 18:38:19 +00:00
|
|
|
if ! diff <(echo "$1") <(echo "$2") ; then
|
2024-04-21 15:54:59 +00:00
|
|
|
fail "Actual value: \"$1\"\nExpected value: \"$2\""
|
2024-02-07 01:22:34 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function assertStringContains() {
|
|
|
|
if ! echo "$1" | grep -q "$2" ; then
|
|
|
|
fail "expected \"$1\" to contain \"$2\""
|
2022-10-21 18:38:19 +00:00
|
|
|
fi
|
|
|
|
}
|