Rob Landley | 1689075 | 2005-09-02 00:41:53 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 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 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=sort; fi |
| 8 | . testing.sh |
| 9 | |
Bernhard Reutner-Fischer | b47a74f | 2005-09-23 15:44:46 +0000 | [diff] [blame] | 10 | # Depends on sort |
| 11 | _BB_CONFIG_DEP=sort |
| 12 | |
Rob Landley | 1689075 | 2005-09-02 00:41:53 +0000 | [diff] [blame] | 13 | # The basic tests. These should work even with the small busybox. |
| 14 | |
| 15 | testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" "" |
| 16 | testing "sort #2" "input" "010\n1\n3\n" "3\n1\n010\n" "" |
| 17 | testing "sort stdin" "" "a\nb\nc\n" "" "b\na\nc\n" |
| 18 | testing "sort numeric" "-n input" "1\n3\n010\n" "3\n1\n010\n" "" |
| 19 | testing "sort reverse" "-r input" "wook\nwalrus\npoint\npabst\naargh\n" \ |
| 20 | "point\nwook\npabst\naargh\nwalrus\n" "" |
| 21 | |
| 22 | # These tests require the full option set. |
| 23 | |
| 24 | # Longish chunk of data re-used by the next few tests |
| 25 | |
| 26 | data="42 1 3 woot |
| 27 | 42 1 010 zoology |
| 28 | egg 1 2 papyrus |
| 29 | 7 3 42 soup |
| 30 | 999 3 0 algebra |
| 31 | " |
| 32 | |
| 33 | # Sorting with keys |
| 34 | |
| 35 | testing "sort one key" "-k4,4 input" \ |
| 36 | "999 3 0 algebra |
| 37 | egg 1 2 papyrus |
| 38 | 7 3 42 soup |
| 39 | 42 1 3 woot |
| 40 | 42 1 010 zoology |
| 41 | " "$data" "" |
| 42 | |
| 43 | testing "sort key range with numeric option" "-k2,3n input" \ |
| 44 | "42 1 010 zoology |
| 45 | 42 1 3 woot |
| 46 | egg 1 2 papyrus |
| 47 | 7 3 42 soup |
| 48 | 999 3 0 algebra |
| 49 | " "$data" "" |
| 50 | |
| 51 | # Busybox is definitely doing this one wrong just now... |
| 52 | |
| 53 | testing "sort key range with numeric option and global reverse" \ |
| 54 | "-k2,3n -r input" \ |
| 55 | "egg 1 2 papyrus |
| 56 | 42 1 3 woot |
| 57 | 42 1 010 zoology |
| 58 | 999 3 0 algebra |
| 59 | 7 3 42 soup |
| 60 | " "$data" "" |
| 61 | |
| 62 | # |
| 63 | |
| 64 | testing "sort key range with multiple options" "-k2,3rn input" \ |
| 65 | "7 3 42 soup |
| 66 | 999 3 0 algebra |
| 67 | 42 1 010 zoology |
| 68 | 42 1 3 woot |
| 69 | egg 1 2 papyrus |
| 70 | " "$data" "" |
| 71 | |
| 72 | exit $FAILCOUNT |