lineedit: invalid unicode characters are replaced with CONFIG_SUBST_WCHAR
[oweals/busybox.git] / testsuite / ash.tests
1 #!/bin/sh
2 #
3 # These are not ash tests, we use ash as a way to test lineedit!
4 #
5 # Copyright 2010 by Denys Vlasenko
6 # Licensed under GPL v2, see file LICENSE for details.
7
8 . ./testing.sh
9
10 # testing "test name" "options" "expected result" "file input" "stdin"
11
12 testing "One byte which is not valid unicode char followed by valid input" \
13         "script -q -c 'ash' /dev/null >/dev/null; cat output; rm output" \
14         "\
15 00000000  3f 2d 0a                                          |?-.|
16 00000003
17 " \
18         "" \
19         "echo \xff- | hexdump -C >output; exit; exit; exit; exit\n" \
20
21 testing "30 bytes which are not valid unicode chars followed by valid input" \
22         "script -q -c 'ash' /dev/null >/dev/null; cat output; rm output" \
23         "\
24 00000000  3f 3f 3f 3f 3f 3f 3f 3f  3f 3f 3f 3f 3f 3f 3f 3f  |????????????????|
25 00000010  3f 3f 3f 3f 3f 3f 3f 3f  3f 3f 3f 3f 3f 3f 2d 0a  |??????????????-.|
26 00000020
27 " \
28         "" \
29         "echo \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff- | hexdump -C >output; exit; exit; exit; exit\n" \
30
31 # Not sure this behavior is perfect: we lose all invalid input which precedes
32 # arrow keys and such. In this example, \xff\xff are lost
33 testing "2 bytes which are not valid unicode chars followed by left arrow key" \
34         "script -q -c 'ash' /dev/null >/dev/null; cat output; rm output" \
35         "\
36 00000000  3d 2d 0a                                          |=-.|
37 00000003
38 " \
39         "" \
40         "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >output; exit; exit; exit; exit\n" \
41
42 exit $FAILCOUNT