blob: aeaae13f01df53fab988be23ecd337f5a9d0a896 [file] [log] [blame]
Denis Vlasenkoe40e76f2008-12-26 14:56:03 +00001#!/bin/sh
2# Copyright 2008 by Denys Vlasenko
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02003# Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenkoe40e76f2008-12-26 14:56:03 +00004
Mike Frysingercaa79402009-11-04 18:41:22 -05005. ./testing.sh
Denys Vlasenko9297dbc2010-07-05 21:37:12 +02006test -f "$bindir/.config" && . "$bindir/.config"
Denis Vlasenkoe40e76f2008-12-26 14:56:03 +00007
8# testing "test name" "options" "expected result" "file input" "stdin"
9
10testing "unexpand case 1" "unexpand" \
11 "\t12345678\n" "" " 12345678\n" \
12
13testing "unexpand case 2" "unexpand" \
14 "\t 12345678\n" "" " 12345678\n" \
15
16testing "unexpand case 3" "unexpand" \
17 "\t 12345678\n" "" " 12345678\n" \
18
19testing "unexpand case 4" "unexpand" \
20 "\t12345678\n" "" " \t12345678\n" \
21
22testing "unexpand case 5" "unexpand" \
23 "\t12345678\n" "" " \t12345678\n" \
24
25testing "unexpand case 6" "unexpand" \
26 "\t12345678\n" "" " \t12345678\n" \
27
28testing "unexpand case 7" "unexpand" \
29 "123\t 45678\n" "" "123 \t 45678\n" \
30
Tomas Heinrich968951f2010-03-26 09:46:07 +010031testing "unexpand case 8" "unexpand" \
32 "a b\n" "" "a b\n" \
33
Mark Edgarb2ab9202020-05-30 19:05:46 +020034testcase()
35{
Denys Vlasenko002be6e2020-06-09 15:58:32 +020036 testing "unexpand flags $*" "unexpand $*" \
37 "$want" "" ' a b c'
Mark Edgarb2ab9202020-05-30 19:05:46 +020038}
39
40# tabs=8, Convert only leading sequences of blanks
41want='\ta b c'
42testcase
43testcase -f
44testcase -f -t8
45testcase -t8 -f
46testcase -t8 --first-only
47
48# tabs=8, Convert all blanks
49want='\ta\tb c'
50testcase -a
51testcase -t8
52testcase -a -t8
53
54# tabs=4, Convert all blanks
55want='\t\ta\t\tb\t c'
56testcase -t4
57testcase -a -t4
58testcase -t4 -a
59
60# tabs=4, Convert only leading sequences of blanks
61want='\t\ta b c'
62testcase -t4 -f
63testcase -f -t4
64testcase -t4 --first-only
65testcase --first-only -t4
66
Denys Vlasenko9297dbc2010-07-05 21:37:12 +020067test x"$CONFIG_UNICODE_SUPPORT" = x"y" \
68&& test x"$CONFIG_UNICODE_USING_LOCALE" != x"y" \
Denys Vlasenkoee1f19b2010-07-06 02:20:00 +020069&& testing "unexpand with unicode characher 0x394" "unexpand" \
Denys Vlasenkoe3d90a92010-05-10 05:53:16 +020070 "1ΔΔΔ5\t99999\n" "" "1ΔΔΔ5 99999\n"
Tomas Heinrichd2b1ba62010-01-04 16:21:31 +010071
Denis Vlasenkoe40e76f2008-12-26 14:56:03 +000072exit $FAILCOUNT