pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/regress/tools Added testsuite for tr(1).



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a8a812ae04fa
branches:  trunk
changeset: 503668:a8a812ae04fa
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Nov 24 19:39:23 2005 +0000

description:
Added testsuite for tr(1).

diffstat:

 regress/tools/Makefile         |   6 +++---
 regress/tools/files/tr-test.sh |  37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)

diffs (61 lines):

diff -r a737003c3493 -r a8a812ae04fa regress/tools/Makefile
--- a/regress/tools/Makefile    Thu Nov 24 19:34:43 2005 +0000
+++ b/regress/tools/Makefile    Thu Nov 24 19:39:23 2005 +0000
@@ -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 @@
 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 -r a737003c3493 -r a8a812ae04fa regress/tools/files/tr-test.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools/files/tr-test.sh    Thu Nov 24 19:39:23 2005 +0000
@@ -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"



Home | Main Index | Thread Index | Old Index