blob: 04d75cfe2e3d0126af9575b0c8ada5edba8f0791 [file] [log] [blame]
Rob Landley16890752005-09-02 00:41:53 +00001#!/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
7if [ ${#COMMAND} -eq 0 ]; then COMMAND=sort; fi
8. testing.sh
9
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +000010# Depends on sort
11_BB_CONFIG_DEP=sort
12
Rob Landley16890752005-09-02 00:41:53 +000013# The basic tests. These should work even with the small busybox.
14
15testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" ""
16testing "sort #2" "input" "010\n1\n3\n" "3\n1\n010\n" ""
17testing "sort stdin" "" "a\nb\nc\n" "" "b\na\nc\n"
18testing "sort numeric" "-n input" "1\n3\n010\n" "3\n1\n010\n" ""
19testing "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
26data="42 1 3 woot
2742 1 010 zoology
28egg 1 2 papyrus
297 3 42 soup
30999 3 0 algebra
31"
32
33# Sorting with keys
34
35testing "sort one key" "-k4,4 input" \
36"999 3 0 algebra
37egg 1 2 papyrus
387 3 42 soup
3942 1 3 woot
4042 1 010 zoology
41" "$data" ""
42
43testing "sort key range with numeric option" "-k2,3n input" \
44"42 1 010 zoology
4542 1 3 woot
46egg 1 2 papyrus
477 3 42 soup
48999 3 0 algebra
49" "$data" ""
50
51# Busybox is definitely doing this one wrong just now...
52
53testing "sort key range with numeric option and global reverse" \
54"-k2,3n -r input" \
55"egg 1 2 papyrus
5642 1 3 woot
5742 1 010 zoology
58999 3 0 algebra
597 3 42 soup
60" "$data" ""
61
62#
63
64testing "sort key range with multiple options" "-k2,3rn input" \
65"7 3 42 soup
66999 3 0 algebra
6742 1 010 zoology
6842 1 3 woot
69egg 1 2 papyrus
70" "$data" ""
71
72exit $FAILCOUNT