@@ -19,7 +19,7 @@ function fail() {
1919
2020function assert_equal() {
2121 if [[ " $1 " != " $2 " ]]; then
22- fail " expected '$1 ', got '$2 ' ${3-} "
22+ fail " expected '$1 ', got '$2 '${3+ : } ${3-}"
2323 fi
2424}
2525
@@ -33,31 +33,38 @@ function assert_equal_files() {
3333 echo " --- SNIP ($2 , size=$( wc " $2 " ) , SHA=$( shasum " $2 " ) ) ---"
3434 cat " $2 "
3535 echo " --- SNAP ($2 ) ---"
36- fail " file '$1 ' not equal to '$2 '"
36+ fail " file '$1 ' not equal to '$2 '${3+ : }${3-} "
3737 fi
3838}
3939
4040function assert_less_than() {
4141 if [[ ! " $1 " -lt " $2 " ]]; then
42- fail " assertion '$1 ' < '$2 ' failed"
42+ fail " assertion '$1 ' < '$2 ' failed${3+ : }${3-} "
4343 fi
4444}
4545
4646function assert_less_than_or_equal() {
4747 if [[ ! " $1 " -le " $2 " ]]; then
48- fail " assertion '$1 ' <= '$2 ' failed"
48+ fail " assertion '$1 ' <= '$2 ' failed${3+ : }${3-} "
4949 fi
5050}
5151
5252function assert_greater_than() {
5353 if [[ ! " $1 " -gt " $2 " ]]; then
54- fail " assertion '$1 ' > '$2 ' failed"
54+ fail " assertion '$1 ' > '$2 ' failed${3+ : }${3-} "
5555 fi
5656}
5757
5858function assert_greater_than_or_equal() {
5959 if [[ ! " $1 " -ge " $2 " ]]; then
60- fail " assertion '$1 ' >= '$2 ' failed"
60+ fail " assertion '$1 ' >= '$2 ' failed${3+: }${3-} "
61+ fi
62+ }
63+
64+ function assert_is_number() {
65+ re=' ^[0-9]+$'
66+ if ! [[ $1 =~ $re ]]; then
67+ fail " $1 is not a number${2+: }${2-} "
6168 fi
6269}
6370
0 commit comments