aboutsummaryrefslogtreecommitdiff
path: root/testsuite/sort.tests
blob: 294530988f7afcc364fb1343f98c9e7d7a84923d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh

# SUSv3 compliant sort tests.
# Copyright 2005 by Rob Landley <rob@landley.net>
# Licensed under GPL v2, see file LICENSE for details.

if [ ${#COMMAND} -eq 0 ]; then COMMAND=sort; fi
. testing.sh

# The basic tests.  These should work even with the small busybox.

testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" ""
testing "sort #2" "input" "010\n1\n3\n" "3\n1\n010\n" ""
testing "sort stdin" "" "a\nb\nc\n" "" "b\na\nc\n"
testing "sort numeric" "-n input" "1\n3\n010\n" "3\n1\n010\n" ""
testing "sort reverse" "-r input" "wook\nwalrus\npoint\npabst\naargh\n" \
	"point\nwook\npabst\naargh\nwalrus\n" ""

# These tests require the full option set.

optional FEATURE_SORT_BIG
# Longish chunk of data re-used by the next few tests

data="42	1	3	woot
42	1	010	zoology
egg	1	2	papyrus
7	3	42	soup
999	3	0	algebra
"

# Sorting with keys

testing "sort one key" "-k4,4 input" \
"999	3	0	algebra
egg	1	2	papyrus
7	3	42	soup
42	1	3	woot
42	1	010	zoology
" "$data" ""

testing "sort key range with numeric option" "-k2,3n input" \
"42	1	010	zoology
42	1	3	woot
egg	1	2	papyrus
7	3	42	soup
999	3	0	algebra
" "$data" ""

# Busybox is definitely doing this one wrong just now.  FIXME

testing "sort key range with numeric option and global reverse" \
"-k2,3n -r input" \
"egg	1	2	papyrus
42	1	3	woot
42	1	010	zoology
999	3	0	algebra
7	3	42	soup
" "$data" ""

# 

testing "sort key range with multiple options" "-k2,3rn input" \
"7	3	42	soup
999	3	0	algebra
42	1	010	zoology
42	1	3	woot
egg	1	2	papyrus
" "$data" ""

exit $FAILCOUNT