diff options
| author | Paul Buetow <paul@buetow.org> | 2023-07-17 05:17:47 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-07-17 05:17:47 +0300 |
| commit | 1ad2c43693f6a61e451c56beea40233db43e0da8 (patch) | |
| tree | 36c79c1e16e9eb625039083bf323dadbdbc295fc /lib/assert.source.sh | |
| parent | 10bded3269bfbdb240f8afd210c80873fe34b12a (diff) | |
| parent | 410d6e1e589c667502431b87d07ba5b6354a5bd8 (diff) | |
Merge branch 'develop'2.1.0
Diffstat (limited to 'lib/assert.source.sh')
| -rw-r--r-- | lib/assert.source.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/assert.source.sh b/lib/assert.source.sh index a1713c3..990194c 100644 --- a/lib/assert.source.sh +++ b/lib/assert.source.sh @@ -31,6 +31,20 @@ assert::not_empty () { log VERBOSE "Result in $callee as expected not empty" } +# Unit test for whether a given string contains a substring +assert::contains () { + local -r content="$1"; shift + local -r substring="$1"; shift + local -r callee=${FUNCNAME[1]} + + if ! $GREP -q -F "$substring" <<< "$content"; then + log ERROR "In $callee expected '$content' to contain substring '$substring'" + exit 2 + fi + + log VERBOSE "Substring check in $callee as expected, contains '$substring'" +} + # Unit test for whether a given string matches a regex. assert::matches () { local -r name="$1"; shift |
