From 0f59f6c7901b521b9a72240f0f83a293b655a60a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 27 Mar 2016 21:46:09 +0200 Subject: m + add rev test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- cat-test/test | 8 +++- rev-test/1.in | 0 rev-test/1.out | 0 rev-test/12345.out | Bin 0 -> 37 bytes rev-test/2.in | 1 + rev-test/2.out | 1 + rev-test/3.in | 1 + rev-test/3.out | 1 + rev-test/4.in | 8 ++++ rev-test/4.out | 8 ++++ rev-test/5.in | Bin 0 -> 20 bytes rev-test/5.out | Bin 0 -> 20 bytes rev-test/comb.in | 1 + rev-test/comb.out | 1 + rev-test/nolf.in | 2 + rev-test/nolf.out | 2 + rev-test/test | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ rev-test/utf8.in | 2 + rev-test/utf8.out | 2 + tac-test/test | 8 +++- test-all | 2 +- 21 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 rev-test/1.in create mode 100644 rev-test/1.out create mode 100644 rev-test/12345.out create mode 100644 rev-test/2.in create mode 100644 rev-test/2.out create mode 100644 rev-test/3.in create mode 100644 rev-test/3.out create mode 100644 rev-test/4.in create mode 100644 rev-test/4.out create mode 100644 rev-test/5.in create mode 100644 rev-test/5.out create mode 100644 rev-test/comb.in create mode 100644 rev-test/comb.out create mode 100644 rev-test/nolf.in create mode 100644 rev-test/nolf.out create mode 100755 rev-test/test create mode 100644 rev-test/utf8.in create mode 100644 rev-test/utf8.out diff --git a/cat-test/test b/cat-test/test index b59188a..1a3d3b3 100755 --- a/cat-test/test +++ b/cat-test/test @@ -59,6 +59,12 @@ file_dash () report $? "file_dash" } +ddash () +{ + diff <($c -- 4) 4 > /dev/null + report $? "ddash" +} + uflag () { touch tmp; rm tmp @@ -78,7 +84,7 @@ uflag () if test $# = 0; then - set $(printf 'file_%i\n' $(seq 1 $N)) dash dash_many file_one file_many file_dash uflag + set $(printf 'file_%i\n' $(seq 1 $N)) dash dash_many file_one file_many file_dash ddash uflag fi ( for f in $@; do diff --git a/rev-test/1.in b/rev-test/1.in new file mode 100644 index 0000000..e69de29 diff --git a/rev-test/1.out b/rev-test/1.out new file mode 100644 index 0000000..e69de29 diff --git a/rev-test/12345.out b/rev-test/12345.out new file mode 100644 index 0000000..c5ad2b3 Binary files /dev/null and b/rev-test/12345.out differ diff --git a/rev-test/2.in b/rev-test/2.in new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/rev-test/2.in @@ -0,0 +1 @@ + diff --git a/rev-test/2.out b/rev-test/2.out new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/rev-test/2.out @@ -0,0 +1 @@ + diff --git a/rev-test/3.in b/rev-test/3.in new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/rev-test/3.in @@ -0,0 +1 @@ +a diff --git a/rev-test/3.out b/rev-test/3.out new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/rev-test/3.out @@ -0,0 +1 @@ +a diff --git a/rev-test/4.in b/rev-test/4.in new file mode 100644 index 0000000..863cbb8 --- /dev/null +++ b/rev-test/4.in @@ -0,0 +1,8 @@ +a +b +c + + +d +e +f diff --git a/rev-test/4.out b/rev-test/4.out new file mode 100644 index 0000000..863cbb8 --- /dev/null +++ b/rev-test/4.out @@ -0,0 +1,8 @@ +a +b +c + + +d +e +f diff --git a/rev-test/5.in b/rev-test/5.in new file mode 100644 index 0000000..cd34f31 Binary files /dev/null and b/rev-test/5.in differ diff --git a/rev-test/5.out b/rev-test/5.out new file mode 100644 index 0000000..2468cbc Binary files /dev/null and b/rev-test/5.out differ diff --git a/rev-test/comb.in b/rev-test/comb.in new file mode 100644 index 0000000..ade0e58 --- /dev/null +++ b/rev-test/comb.in @@ -0,0 +1 @@ +a̐b̐ diff --git a/rev-test/comb.out b/rev-test/comb.out new file mode 100644 index 0000000..c142ffc --- /dev/null +++ b/rev-test/comb.out @@ -0,0 +1 @@ +b̐a̐ diff --git a/rev-test/nolf.in b/rev-test/nolf.in new file mode 100644 index 0000000..3effb8b --- /dev/null +++ b/rev-test/nolf.in @@ -0,0 +1,2 @@ +abc +123 \ No newline at end of file diff --git a/rev-test/nolf.out b/rev-test/nolf.out new file mode 100644 index 0000000..c562183 --- /dev/null +++ b/rev-test/nolf.out @@ -0,0 +1,2 @@ +cba +321 \ No newline at end of file diff --git a/rev-test/test b/rev-test/test new file mode 100755 index 0000000..4cff0bc --- /dev/null +++ b/rev-test/test @@ -0,0 +1,109 @@ +#!/bin/bash + +cd -- "$(dirname "$0")" +if test -z "$REV"; then + REV=../rev +fi +N=5 +r="$PREFIX $REV" + +report () +{ + if test $1 = 0; then + printf "\033[1;32mTest %s OK\033[m\n" "$2" + else + printf "\033[1;31mTest %s FAILED\033[m\n" "$2" + fi +} + +report_np () +{ + if test $1 = 0; then + printf "\033[1;32mTest %s OK (NON-STANDARD)\033[m\n" "$2" + else + printf "\033[1;31mTest %s FAILED (NON-STANDARD)\033[m\n" "$2" + fi +} + +test_file () +{ + diff <($r < $1.in) $1.out > /dev/null + report $? "file_$1" +} + + +file_1 () { test_file 1; } +file_2 () { test_file 2; } +file_3 () { test_file 3; } +file_4 () { test_file 4; } +file_5 () { test_file 5; } + +nolf () +{ + diff <($r < nolf.in) nolf.out > /dev/null + report_np $? "nolf" +} + +utf8 () +{ + diff <($r < utf8.in) utf8.out > /dev/null + report $? "utf8" +} + +dash () +{ + diff <($r - < 4.in) 4.out > /dev/null + report $? "dash" +} + +file_one () +{ + diff <($r 4.in) 4.out > /dev/null + report $? "file_one" +} + +file_many () +{ + diff <($r 1.in 2.in 3.in 4.in 5.in) 12345.out > /dev/null + report $? "file_many" +} + +file_dash () +{ + diff <($r 1.in 2.in 3.in 4.in - < 5.in) 12345.out > /dev/null + report $? "file_dash" +} + +ddash () +{ + diff <($r -- 4.in) 4.out > /dev/null + report $? "ddash" +} + +combining () +{ + diff <($r < comb.in) comb.out > /dev/null + report_np $? "combining" + # How would you define “character”? +} + + +if test $# = 0; then + set $(printf 'file_%i\n' $(seq 1 $N)) dash nolf utf8 file_one file_many file_dash ddash combining +fi +( +for f in $@; do + $f +done +) | tee result +! grep FAILED < result > /dev/null +ret=$? +if test $ret != 0; then + if test $(grep FAILED < result | grep -v NON-STANDARD | wc -l) = 0; then + ret=1 + else + ret=2 + fi +fi +rm result +exit $ret diff --git a/rev-test/utf8.in b/rev-test/utf8.in new file mode 100644 index 0000000..2382c2d --- /dev/null +++ b/rev-test/utf8.in @@ -0,0 +1,2 @@ +åäö +𝐀𝐁𝐂 diff --git a/rev-test/utf8.out b/rev-test/utf8.out new file mode 100644 index 0000000..9d77c39 --- /dev/null +++ b/rev-test/utf8.out @@ -0,0 +1,2 @@ +öäå +𝐂𝐁𝐀 diff --git a/tac-test/test b/tac-test/test index 769e226..db4e121 100755 --- a/tac-test/test +++ b/tac-test/test @@ -53,9 +53,15 @@ file_dash () report $? "file_dash" } +ddash () +{ + diff <($t -- 4.in) 4.out > /dev/null + report $? "ddash" +} + if test $# = 0; then - set $(printf 'file_%i\n' $(seq 1 $N)) dash file_one file_many file_dash + set $(printf 'file_%i\n' $(seq 1 $N)) dash file_one file_many file_dash ddash fi ( for f in $@; do diff --git a/test-all b/test-all index e5d16e1..4f85ddb 100755 --- a/test-all +++ b/test-all @@ -7,7 +7,7 @@ function all() echo patch md5sum rawshake256sum rawshake512sum sha1sum sha224sum sha256sum sha3-224sum \ sha3-256sum sha3-384sum sha3-512sum sha384sum sha512-224sum sha512-256sum sha512sum \ shake256sum shake512sum cksum true false echo test basename dirname uniq cat yes \ - tac + tac rev } exec 99>&2 -- cgit v1.2.3-70-g09d2