xref: /freebsd/lib/libc/tests/regex/multibyte.sh (revision 84b3c4547afa496b37e86c5e649e99237c8afc6e)
1# $FreeBSD$
2
3atf_test_case bmpat
4bmpat_head()
5{
6	atf_set "descr" "Check matching multibyte characters (PR153502)"
7}
8bmpat_body()
9{
10	export LC_CTYPE="C.UTF-8"
11
12	printf 'é' | atf_check -o "inline:é" \
13	    sed -ne '/^.$/p'
14	printf 'éé' | atf_check -o "inline:éé" \
15	    sed -ne '/^..$/p'
16	printf 'aéa' | atf_check -o "inline:aéa" \
17	    sed -ne '/a.a/p'
18	printf 'aéa'| atf_check -o "inline:aéa" \
19	    sed -ne '/a.*a/p'
20	printf 'aaéaa' | atf_check -o "inline:aaéaa" \
21	    sed -ne '/aa.aa/p'
22	printf 'aéaéa' | atf_check -o "inline:aéaéa" \
23	    sed -ne '/a.a.a/p'
24	printf 'éa' | atf_check -o "inline:éa" \
25	    sed -ne '/.a/p'
26	printf 'aéaa' | atf_check -o "inline:aéaa" \
27	    sed -ne '/a.aa/p'
28	printf 'éaé' | atf_check -o "inline:éaé" \
29	    sed -ne '/.a./p'
30}
31
32atf_test_case icase
33icase_head()
34{
35	atf_set "descr" "Check case-insensitive matching for characters 128-255"
36}
37icase_body()
38{
39	export LC_CTYPE="C.UTF-8"
40
41	a=$(printf '\302\265\n')	# U+00B5
42	b=$(printf '\316\234\n')	# U+039C
43	c=$(printf '\316\274\n')	# U+03BC
44
45	echo $b | atf_check -o "inline:$b\n" sed -ne "/$a/Ip"
46	echo $c | atf_check -o "inline:$c\n" sed -ne "/$a/Ip"
47}
48
49atf_init_test_cases()
50{
51	atf_add_test_case bmpat
52	atf_add_test_case icase
53}
54