Luke Granger-Brown
57725ef3ec
git-subtree-dir: third_party/nixpkgs git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
21 lines
442 B
Bash
21 lines
442 B
Bash
# Always failing assertion with a message.
|
|
#
|
|
# Example:
|
|
# fail "It should have been but it wasn't to be"
|
|
function fail() {
|
|
echo -e "$1"
|
|
exit 1
|
|
}
|
|
|
|
|
|
function assertStringEqual() {
|
|
if ! diff <(echo "$1") <(echo "$2") ; then
|
|
fail "Actual value: \"$1\"\nExpected value: \"$2\""
|
|
fi
|
|
}
|
|
|
|
function assertStringContains() {
|
|
if ! echo "$1" | grep -q "$2" ; then
|
|
fail "expected \"$1\" to contain \"$2\""
|
|
fi
|
|
}
|