Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (50 sloc) 1.155 kb
#!/bin/bash
#
# these are written strangely because all APRON_assert_*
# functions are run with an error trap. We want to make
# sure the trap is triggered on error.
#
#
# Numeric assertions
#
APRON_assert_eq() {
(( $1 == $2 ))
(( $? )) && printf 'Assertion failed: %d == %d\n' "$1" "$2"
}
APRON_assert_ne() {
(( $1 != $2 ))
(( $? )) && printf 'Assertion failed: %d != %d\n' "$1" "$2"
}
APRON_assert_lt() {
(( $1 < $2 ))
(( $? )) && printf 'Assertion failed: %d < %d\n' "$1" "$2"
}
APRON_assert_le() {
(( $1 <= $2 ))
(( $? )) && printf 'Assertion failed: %d <= %d\n' "$1" "$2"
}
APRON_assert_gt() {
(( $1 > $2 ))
(( $? )) && printf 'Assertion failed: %d > %d\n' "$1" "$2"
}
APRON_assert_ge() {
(( $1 >= $2 ))
(( $? )) && printf 'Assertion failed: %d >= %d\n' "$1" "$2"
}
#
# String based assertions
#
APRON_assert_streq() {
[[ $1 == "$2" ]]
(( $? )) && printf 'Assertion failed: "%s" != "%s"\n' "$1" "$2"
}
APRON_assert_in() {
for i in "${@:2}"; do
if [[ $1 = "$i" ]]; then
return 0
fi
done
false
printf 'Assertion failed: "%s" not found in: %s\n' "$1" "${*:2}"
}
# vim: set ft=sh et ts=2 sw=2:
Jump to Line
Something went wrong with that request. Please try again.