aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-27 21:46:09 +0200
committerMattias Andrée <maandree@kth.se>2016-03-27 21:46:09 +0200
commit0f59f6c7901b521b9a72240f0f83a293b655a60a (patch)
tree0181ed5338ba8c554888762c7471712ab323fd35
parentadd tac test (diff)
downloadbase-util-tests-0f59f6c7901b521b9a72240f0f83a293b655a60a.tar.gz
base-util-tests-0f59f6c7901b521b9a72240f0f83a293b655a60a.tar.bz2
base-util-tests-0f59f6c7901b521b9a72240f0f83a293b655a60a.tar.xz
m + add rev test
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rwxr-xr-xcat-test/test8
-rw-r--r--rev-test/1.in0
-rw-r--r--rev-test/1.out0
-rw-r--r--rev-test/12345.outbin0 -> 37 bytes
-rw-r--r--rev-test/2.in1
-rw-r--r--rev-test/2.out1
-rw-r--r--rev-test/3.in1
-rw-r--r--rev-test/3.out1
-rw-r--r--rev-test/4.in8
-rw-r--r--rev-test/4.out8
-rw-r--r--rev-test/5.inbin0 -> 20 bytes
-rw-r--r--rev-test/5.outbin0 -> 20 bytes
-rw-r--r--rev-test/comb.in1
-rw-r--r--rev-test/comb.out1
-rw-r--r--rev-test/nolf.in2
-rw-r--r--rev-test/nolf.out2
-rwxr-xr-xrev-test/test109
-rw-r--r--rev-test/utf8.in2
-rw-r--r--rev-test/utf8.out2
-rwxr-xr-xtac-test/test8
-rwxr-xr-xtest-all2
21 files changed, 154 insertions, 3 deletions
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
--- /dev/null
+++ b/rev-test/1.in
diff --git a/rev-test/1.out b/rev-test/1.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/rev-test/1.out
diff --git a/rev-test/12345.out b/rev-test/12345.out
new file mode 100644
index 0000000..c5ad2b3
--- /dev/null
+++ b/rev-test/12345.out
Binary files 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
--- /dev/null
+++ b/rev-test/5.in
Binary files differ
diff --git a/rev-test/5.out b/rev-test/5.out
new file mode 100644
index 0000000..2468cbc
--- /dev/null
+++ b/rev-test/5.out
Binary files 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