From b253915c629c6d38641a81c7f1bb47d662c48a03 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 9 Apr 2023 13:21:29 +0300 Subject: add support for GNU Source Highlight - for Source code highlighting in bare blocks --- lib/assert.source.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/assert.source.sh') 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 -- cgit v1.2.3