diff options
author | rillig <rillig> | 2005-11-24 19:39:23 +0000 |
---|---|---|
committer | rillig <rillig> | 2005-11-24 19:39:23 +0000 |
commit | ff4852cf8c6a68508dc0566a7a75ee17bbe1cc85 (patch) | |
tree | c704ced0aad60a130cae78fba110f521c660146d /regress/tools | |
parent | 0b0aaf6a8b7149463f723c192a19ecc1c6bf5202 (diff) | |
download | pkgsrc-ff4852cf8c6a68508dc0566a7a75ee17bbe1cc85.tar.gz |
Added testsuite for tr(1).
Diffstat (limited to 'regress/tools')
-rw-r--r-- | regress/tools/Makefile | 6 | ||||
-rw-r--r-- | regress/tools/files/tr-test.sh | 37 |
2 files changed, 40 insertions, 3 deletions
diff --git a/regress/tools/Makefile b/regress/tools/Makefile index 6f713a722d8..f926d7428b5 100644 --- a/regress/tools/Makefile +++ b/regress/tools/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2005/11/19 22:03:54 rillig Exp $ +# $NetBSD: Makefile,v 1.3 2005/11/24 19:39:23 rillig Exp $ # DISTNAME= regress-tools-1.0 @@ -9,8 +9,8 @@ MAINTAINER= rillig@NetBSD.org COMMENT= Test whether the TOOLS do what I expect WRKSRC= ${WRKDIR} -REGRESS_TESTS= awk -USE_TOOLS+= awk +REGRESS_TESTS= awk tr +USE_TOOLS+= awk tr do-build: .for t in ${REGRESS_TESTS} diff --git a/regress/tools/files/tr-test.sh b/regress/tools/files/tr-test.sh new file mode 100644 index 00000000000..071b8fbb5a3 --- /dev/null +++ b/regress/tools/files/tr-test.sh @@ -0,0 +1,37 @@ +#! /bin/sh +# $NetBSD: tr-test.sh,v 1.1 2005/11/24 19:39:23 rillig Exp $ +# + +set -e + +mydir=`dirname "$0"` +. "${mydir}/tests.subr" + +# +# Functions specific for the tr testsuite. +# + +# usage: tr_test <testname> <input> <expected-output> <args...> +tr_test() { + testname=$1; input=$2; expected=$3; shift 3; + + testcase_start "${testname}" + output=`tr "$@" <<EOF +$input +EOF +` + assert_equal "${testname}" "${expected}" "${output}" +} + +# +# The actual test. +# +nl=" +" + +tr_test "simple" \ + "foo" "baa" "fo" "ba" +tr_test "tolower" \ + "The Great Green Fox" "the great green fox" "A-Z" "a-z" +tr_test "eat-newlines" \ + "foo${nl}bar${nl}" "foobar" -d "\\n" |