diff options
Diffstat (limited to 'regress/tools/files/tests.subr')
-rw-r--r-- | regress/tools/files/tests.subr | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/regress/tools/files/tests.subr b/regress/tools/files/tests.subr new file mode 100644 index 00000000000..204657b364a --- /dev/null +++ b/regress/tools/files/tests.subr @@ -0,0 +1,33 @@ +# $NetBSD: tests.subr,v 1.1 2005/11/24 19:18:45 rillig Exp $ +# + +# usage: testcase_start <testname> +testcase_start() { + printf " Running testcase %s\\n" "$1" +} + +# usage: assert_equal <testname> <expected> <got> +assert_equal() { + case $2 in + "$3") ;; + *) echo "[assert_equal:$1] expected \"$2\", got \"$3\"." 1>&2 + return 1;; + esac +} + +# usage: test_assignment <testname> <input> <expected-output> +test_assignment() { + testcase_start "$1" + o=`echo "" | awk '{print var}' var="$2"` + assert_equal "$1" "$3" "${o}" +} + +# usage: test_passline <testname> <input> +test_passline() { + testcase_start "$1" + o=`awk '{print}' <<EOF +$2 +EOF +` + assert_equal "$1" "$2" "${o}" +} |