comparison tests/wc.test @ 1485:8700cbe1cb29 draft

Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
author Rob Landley <rob@landley.net>
date Sat, 20 Sep 2014 13:09:14 -0500
parents scripts/test/wc.test@cfdaead45479
children
comparison
equal deleted inserted replaced
1484:19435f12ec63 1485:8700cbe1cb29
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 #testing "name" "command" "result" "infile" "stdin"
6
7 cat >file1 <<EOF
8 some words .
9
10 some
11 lines
12 EOF
13
14 testing "wc" "wc >/dev/null && echo yes" "yes\n" "" ""
15 testing "wc empty file" "wc" "0 0 0\n" "" ""
16 testing "wc standard input" "wc" "1 3 5\n" "" "a b\nc"
17 testing "wc -c" "wc -c file1" "26 file1\n" "" ""
18 testing "wc -l" "wc -l file1" "4 file1\n" "" ""
19 testing "wc -w" "wc -w file1" "5 file1\n" "" ""
20 testing "wc format" "wc file1" "4 5 26 file1\n" "" ""
21 testing "wc multiple files" "wc input - file1" \
22 "1 2 3 input\n0 2 3 -\n4 5 26 file1\n5 9 32 total\n" "a\nb" "a b"
23
24 optional TOYBOX_I18N
25
26 #Tests for wc -m
27 if printf "%s" "$LANG" | grep -q UTF-8
28 then
29
30 printf " " > file1
31 for i in $(seq 1 8192)
32 do
33 printf "ü" >> file1
34 done
35 testing "wc -m" "wc -m file1" "8193 file1\n" "" ""
36 printf " " > file1
37 for i in $(seq 1 8192)
38 do
39 printf "ü" >> file1
40 done
41 testing "wc -m (invalid chars)" "wc -m file1" "8193 file1\n" "" ""
42 testing "wc -mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" ""
43
44 else
45 printf "skipping tests for wc -m"
46 fi
47
48 rm file1