3 # SUSv3 compliant sort tests.
4 # Copyright 2005 by Rob Landley <rob@landley.net>
5 # Licensed under GPLv2, see file LICENSE in this source tree.
9 # The basic tests. These should work even with the small busybox.
11 testing "sort" "sort input" "a\nb\nc\n" "c\na\nb\n" ""
12 testing "sort #2" "sort input" "010\n1\n3\n" "3\n1\n010\n" ""
13 testing "sort stdin" "sort" "a\nb\nc\n" "" "b\na\nc\n"
14 testing "sort numeric" "sort -n input" "1\n3\n010\n" "3\n1\n010\n" ""
15 testing "sort reverse" "sort -r input" "wook\nwalrus\npoint\npabst\naargh\n" \
16 "point\nwook\npabst\naargh\nwalrus\n" ""
18 # These tests require the full option set.
20 optional FEATURE_SORT_BIG
21 # Longish chunk of data re-used by the next few tests
30 # testing "description" "command(s)" "result" "infile" "stdin"
34 testing "sort one key" "sort -k4,4 input" \
42 testing "sort key range with numeric option" "sort -k2,3n input" \
50 testing "sort key range with numeric option and global reverse" \
51 "sort -k2,3n -r input" \
59 testing "sort key range with multiple options" "sort -k2,3rn input" \
67 testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
77 testing "sort with non-default leading delim 1" "sort -n -k2 -t/ input" "\
85 testing "sort with non-default leading delim 2" "sort -n -k3 -t/ input" "\
93 testing "sort with non-default leading delim 3" "sort -n -k3 -t/ input" "\
101 testing "sort with non-default leading delim 4" "sort -t: -k1,1 input" "\
109 testing "sort with ENDCHAR" "sort -t. -k1,1.1 -k2 input" "\
117 testing "glibc build sort" "sort -t. -k 1,1 -k 2n,2n -k 3 input" "\
135 testing "glibc build sort unique" "sort -u -t. -k 1,1 -k 2n,2n -k 3 input" "\
153 testing "sort -u should consider field only when discarding" "sort -u -k2 input" "\
160 testing "sort -z outputs NUL terminated lines" "sort -z input" "\
166 testing "sort key doesn't strip leading blanks, disables fallback global sort" \
167 "sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n"
169 testing "sort file in place" \
170 "sort -o input input && cat input" "\
178 # testing "description" "command(s)" "result" "infile" "stdin"