Added tests

This commit is contained in:
Dylan Araps 2018-06-14 18:50:53 +10:00
parent 8140a47dfb
commit 51013c49c5
1 changed files with 27 additions and 0 deletions

27
test.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
#
# Tests for the Pure Bash Bible.
assert_equals() {
# Test equality.
local status
[[ "$1" == "$2" ]] && status="✔"
printf '%s\n' " ${status:-} : ${FUNCNAME[1]}"
[[ "$1" == "$2" ]] || { :>/tmp/err; return 1; } && return 0
}
test_trim() {
result="$(trim " Hello, World ")"
assert_equals "$result" "Hello, World"
}
main() {
source <(awk '/```sh/{f=1;next}/```/{f=0}f' README.md) 2>/dev/null
test_trim
[[ -f /tmp/err ]] || exit 0 && { rm /tmp/err; exit 1; }
}
main "$@"