OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD am: 14cafec540
[android-x86/external-toybox.git] / tests / wc.test
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 "empty file" "wc" "      0       0       0\n" "" ""
16 testing "standard input" "wc" "      1       3       5\n" "" "a b\nc"
17 testing "-c" "wc -c file1" "26 file1\n" "" ""
18 testing "-l" "wc -l file1" "4 file1\n" "" ""
19 testing "-w" "wc -w file1" "5 file1\n" "" ""
20 NOSPACE=1 testing "format" "wc file1" " 4 5 26 file1\n" "" ""
21 testing "multiple files" "wc input - file1" \
22         "      1       2       3 input\n      0       2       3 -\n      4       5      26 file1\n      5       9      32 total\n" "a\nb" "a b"
23
24 #Tests for wc -m
25 echo -n " " > file1
26 for i in $(seq 1 512); do echo -n "üüüüüüüüüüüüüüüü" >> file1; done
27 testing "-m" "wc -m file1" "8193 file1\n" "" ""
28 testing "-m 2" 'cat "$FILES/utf8/test2.txt" | wc -m' "169\n" "" ""
29 echo -n " " > file1
30 NOSPACE=1 testing "-mlw" "wc -mlw input" " 1 2 11 input\n" "hello, 世界!\n" ""
31 rm file1