annotate tests/wc.test @ 1650:a740a876c76c draft

Cleanup pass on printf. Alas, passing a union as the last argument to printf does not appear to work reliably, and there's no obvious way to manually assemble varargs in a portable manner. So I have to repeat the printf once for each data type. Oh well.
author Rob Landley <rob@landley.net>
date Sun, 11 Jan 2015 01:22:36 -0600
parents 8700cbe1cb29
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
682
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
1 #!/bin/bash
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
2
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
4
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
5 #testing "name" "command" "result" "infile" "stdin"
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
6
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
7 cat >file1 <<EOF
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
8 some words .
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
9
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
10 some
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
11 lines
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
12 EOF
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
13
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
14 testing "wc" "wc >/dev/null && echo yes" "yes\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
15 testing "wc empty file" "wc" "0 0 0\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
16 testing "wc standard input" "wc" "1 3 5\n" "" "a b\nc"
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
17 testing "wc -c" "wc -c file1" "26 file1\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
18 testing "wc -l" "wc -l file1" "4 file1\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
19 testing "wc -w" "wc -w file1" "5 file1\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
20 testing "wc format" "wc file1" "4 5 26 file1\n" "" ""
686
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
21 testing "wc multiple files" "wc input - file1" \
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
22 "1 2 3 input\n0 2 3 -\n4 5 26 file1\n5 9 32 total\n" "a\nb" "a b"
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
23
710
cfdaead45479 Make internalization support optional
Felix Janda <felix.janda@posteo.de>
parents: 686
diff changeset
24 optional TOYBOX_I18N
cfdaead45479 Make internalization support optional
Felix Janda <felix.janda@posteo.de>
parents: 686
diff changeset
25
686
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
26 #Tests for wc -m
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
27 if printf "%s" "$LANG" | grep -q UTF-8
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
28 then
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
29
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
30 printf " " > file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
31 for i in $(seq 1 8192)
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
32 do
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
33 printf "ü" >> file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
34 done
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
35 testing "wc -m" "wc -m file1" "8193 file1\n" "" ""
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
36 printf " " > file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
37 for i in $(seq 1 8192)
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
38 do
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
39 printf "ü" >> file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
40 done
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
41 testing "wc -m (invalid chars)" "wc -m file1" "8193 file1\n" "" ""
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
42 testing "wc -mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" ""
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
43
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
44 else
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
45 printf "skipping tests for wc -m"
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
46 fi
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
47
682
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
48 rm file1