summaryrefslogtreecommitdiff
path: root/packages/assert.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <git@mx.buetow.org>2021-05-21 05:18:10 +0100
committerPaul Buetow <git@mx.buetow.org>2021-05-21 05:18:10 +0100
commit85df071aa1a5aa73328fdc5969d3ca0ed9df2c08 (patch)
treeec8c11c9e1ad5dfa02c15e57212b239b75e52c87 /packages/assert.source.sh
parent9dbd7f008192fd506bf642944232334fad0ed55c (diff)
add readme
Diffstat (limited to 'packages/assert.source.sh')
-rw-r--r--packages/assert.source.sh59
1 files changed, 0 insertions, 59 deletions
diff --git a/packages/assert.source.sh b/packages/assert.source.sh
deleted file mode 100644
index d53a728e..00000000
--- a/packages/assert.source.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-# Unit test for whether 2 given strings equal.
-assert::equals () {
- local -r result="$1"; shift
- local -r expected="$1"; shift
- local -r callee=${FUNCNAME[1]}
-
- if [[ "$result" != "$expected" ]]; then
- cat <<ERROR | log::pipe ERROR
-In $callee expected
- '$expected'
-But got
- '$result'
-ERROR
- exit 2
- fi
-
- log VERBOSE "Result in $callee as expected: '$expected'"
-}
-
-# Unit test for whether a given string is not empty.
-assert::not_empty () {
- local -r name="$1"; shift
- local -r content="$1"; shift
- local -r callee=${FUNCNAME[1]}
-
- if [ -z "$content" ]; then
- log ERROR "In $callee expected '$name' not to be empty!"
- exit 2
- fi
-
- log VERBOSE "Result in $callee as expected not empty"
-}
-
-# Unit test for whether a given string matches a regex.
-assert::matches () {
- local -r name="$1"; shift
- local -r content="$1"; shift
- local -r regex="$1"; shift
- local -r callee=${FUNCNAME[1]}
-
- if ! $GREP -q -E "$regex" <<< "$content"; then
- log ERROR "In $callee expected '$name' to match '$regex'"
- exit 2
- fi
-
- log VERBOSE "Matching in $callee as expected"
-}
-
-# Checks if all the Bash scripts here are good.
-assert::shellcheck () {
- set -e
- shellcheck \
- --norc \
- --external-sources \
- --check-sourced \
- --exclude=SC2155,SC2010,SC2154,SC1090,SC2012 \
- ./"$0"
- set +e
-}