diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-08-28 12:39:08 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-08-28 12:39:08 +0000 |
commit | 38090f306d17aeea01e76ff29292652a463b08cd (patch) | |
tree | 40494dc55a7e7d444573b01f499b293102e37d40 /regress/usr.bin | |
parent | 38f2491dbfd2c6f3400ef0dc3b04739987e6b9e5 (diff) |
I don't dare to provide an OK for a rewrite of this program
without having at least some systematic testing in place.
Diffstat (limited to 'regress/usr.bin')
-rw-r--r-- | regress/usr.bin/column/Makefile | 6 | ||||
-rw-r--r-- | regress/usr.bin/column/column.sh | 64 |
2 files changed, 70 insertions, 0 deletions
diff --git a/regress/usr.bin/column/Makefile b/regress/usr.bin/column/Makefile new file mode 100644 index 00000000000..6de0d261c5b --- /dev/null +++ b/regress/usr.bin/column/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1 2016/08/28 12:39:07 schwarze Exp $ + +regress: + @sh ${.CURDIR}/column.sh + +.include <bsd.regress.mk> diff --git a/regress/usr.bin/column/column.sh b/regress/usr.bin/column/column.sh new file mode 100644 index 00000000000..ec9359ac0ba --- /dev/null +++ b/regress/usr.bin/column/column.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# +# Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +fail=0 + +tc1() +{ + expected=$(echo -n "$3") + result=$(echo -n "$1" | /usr/old/column $2) + if [ "X$result" != "X$expected" ]; then + fail=$((fail+1)) + echo "argument: '$2'" + echo "input: '$1'" + echo "expected: '$expected'" + echo "result: '$result'" + fi +} + +tc() +{ + input=$1 + shift + while [ $# -gt 1 ]; do + tc1 "$input" "$1" "$2" + shift 2 + done +} + +tc "1\n2\n\n3\n \t \n4" \ + "-c 7" "1\n2\n3\n4\n" \ + "-c 15" "1\n2\n3\n4\n" \ + "-c 16" "1\t3\n2\t4\n" \ + "-xc 7" "1\n2\n3\n4\n" \ + "-xc 16" "1\t2\n3\t4\n" +tc "one\ntwo\nthree\nfour\nfive\nsix\n seven\neight\n" \ + "-c 23" "one\tfive\ntwo\tsix\nthree\t seven\nfour\teight\n" \ + "-xc 23" "one\ttwo\nthree\tfour\nfive\tsix\n seven\teight\n" \ + "-c 24" "one\tfour\t seven\ntwo\tfive\teight\nthree\tsix\n" \ + "-xc 24" "one\ttwo\tthree\nfour\tfive\tsix\n seven\teight\n" +tc "eleven\ntwelve\nthirteen\n" \ + "-c 31" "eleven\ntwelve\nthirteen\n" \ + "-c 32" "eleven\t\tthirteen\ntwelve\n" \ + "-xc 32" "eleven\t\ttwelve\nthirteen\n" +tc1 ".,word.,\n\t \t\n\nx.word\n" "-t -s .," "word\nx word\n" +tc1 "1 2 3\n4 5\n" "-t" "1 2 3\n4 5\n" +tc1 "abc\tbc\tc\nab\tabc\tbc\na\tab\tabc\n" \ + "-t" "abc bc c\nab abc bc\na ab abc\n" + +[ $fail -eq 0 ] && exit 0 +echo "column: $fail tests failed" +exit 1 |