diff options
Diffstat (limited to 'testsuite/sort.tests')
-rwxr-xr-x | testsuite/sort.tests | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/testsuite/sort.tests b/testsuite/sort.tests new file mode 100755 index 000000000..5a4937b58 --- /dev/null +++ b/testsuite/sort.tests | |||
@@ -0,0 +1,83 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # SUSv3 compliant sort tests. | ||
4 | # Copyright 2005 by Rob Landley <rob@landley.net> | ||
5 | # Licensed under GPL v2, see file LICENSE for details. | ||
6 | |||
7 | . testing.sh | ||
8 | |||
9 | # The basic tests. These should work even with the small busybox. | ||
10 | |||
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" "" | ||
17 | |||
18 | # These tests require the full option set. | ||
19 | |||
20 | optional FEATURE_SORT_BIG | ||
21 | # Longish chunk of data re-used by the next few tests | ||
22 | |||
23 | data="42 1 3 woot | ||
24 | 42 1 010 zoology | ||
25 | egg 1 2 papyrus | ||
26 | 7 3 42 soup | ||
27 | 999 3 0 algebra | ||
28 | " | ||
29 | |||
30 | # Sorting with keys | ||
31 | |||
32 | testing "sort one key" "sort -k4,4 input" \ | ||
33 | "999 3 0 algebra | ||
34 | egg 1 2 papyrus | ||
35 | 7 3 42 soup | ||
36 | 42 1 3 woot | ||
37 | 42 1 010 zoology | ||
38 | " "$data" "" | ||
39 | |||
40 | testing "sort key range with numeric option" "sort -k2,3n input" \ | ||
41 | "42 1 010 zoology | ||
42 | 42 1 3 woot | ||
43 | egg 1 2 papyrus | ||
44 | 7 3 42 soup | ||
45 | 999 3 0 algebra | ||
46 | " "$data" "" | ||
47 | |||
48 | # Busybox is definitely doing this one wrong just now. FIXME | ||
49 | |||
50 | testing "sort key range with numeric option and global reverse" \ | ||
51 | "sort -k2,3n -r input" \ | ||
52 | "egg 1 2 papyrus | ||
53 | 42 1 3 woot | ||
54 | 42 1 010 zoology | ||
55 | 999 3 0 algebra | ||
56 | 7 3 42 soup | ||
57 | " "$data" "" | ||
58 | |||
59 | # | ||
60 | |||
61 | testing "sort key range with multiple options" "sort -k2,3rn input" \ | ||
62 | "7 3 42 soup | ||
63 | 999 3 0 algebra | ||
64 | 42 1 010 zoology | ||
65 | 42 1 3 woot | ||
66 | egg 1 2 papyrus | ||
67 | " "$data" "" | ||
68 | |||
69 | testing "sort key doesn't strip leading blanks, disables fallback global sort" \ | ||
70 | "sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n" | ||
71 | |||
72 | testing "sort key edge case with -t" "sort -n -k4 -t/" \ | ||
73 | "/usr/lib/finish-install.d/1 | ||
74 | /usr/lib/finish-install.d/4 | ||
75 | /usr/lib/prebaseconfig.d/2 | ||
76 | /usr/lib/prebaseconfig.d/6 | ||
77 | " "" "/usr/lib/finish-install.d/1 | ||
78 | /usr/lib/prebaseconfig.d/2 | ||
79 | /usr/lib/finish-install.d/4 | ||
80 | /usr/lib/prebaseconfig.d/6 | ||
81 | " | ||
82 | |||
83 | exit $FAILCOUNT | ||