summaryrefslogtreecommitdiff
path: root/regress/tools/files/sort-test.sh
blob: f1bae3a51810131fc120a8a9f748b107c79f73c4 (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
#! /bin/sh
# $NetBSD: sort-test.sh,v 1.1 2006/06/25 21:47:28 rillig Exp $
#

set -e

mydir=`dirname "$0"`
. "${mydir}/tests.subr"

#
# Functions specific for the "sort" testsuite.
#

# usage: sort_test <testname> <input> <expected-output> <args...>
sort_test() {
	testname=$1; input=$2; expected=$3; shift 3;

	testcase_start "${testname}"
	output=`sort "$@" <<EOF
$input
EOF
`
	assert_equal "${testname}" "${expected}" "${output}"
}

#
# The actual test.
#

nl="
"

sort_test "one line" \
	"text line 1" "text line 1"
sort_test "uppercase letters" \
	"A${nl}B${nl}C" "A${nl}B${nl}C"
sort_test "A < C < b" \
	"A${nl}b${nl}C" "A${nl}C${nl}b"