assertions.sh 660 B

123456789101112131415161718192021222324252627282930
  1. assert_empty_str() {
  2. local name=${1:?}
  3. local result=${2:?}
  4. [[ "" == "$result" ]] || echo "$name: '' != $result"
  5. }
  6. assert_not_equal() {
  7. local name=${1:?}
  8. local expectation=${2:?}
  9. local result=${3:-}
  10. [[ "$expectation" != "$result" ]] || echo "$name: $expectation != $result"
  11. }
  12. assert_equal() {
  13. local name=${1:?}
  14. local expectation=${2:?}
  15. local result=${3:?}
  16. [[ "$expectation" == "$result" ]] || echo "$name: $expectation != $result"
  17. }
  18. assert_exit_status() {
  19. local name=${1:?}
  20. local expectation=${2:?}
  21. local result=${3:?}
  22. [ "$expectation" -eq "$result" ] || echo "$name: $expectation != $result"
  23. }