1echo T.utfre: tests of regular expression code for Unicode/utf-8
2# adapted from T.re
3
4awk '
5BEGIN {
6	FS = "\t"
7	awk = "../a.out"
8}
9NF == 0 {
10	next
11}
12$1 != "" {	# new test
13	re = $1
14}
15$2 != "" {	# either ~ or !~
16	op = $2
17	if (op == "~")
18		neg = "!"
19	else if (op == "!~")
20		neg = ""
21}
22$3 != "" {	# new test string
23	str = $3
24}
25$3 == "\"\"" {	# explicit empty line
26	$3 = ""
27}
28NF > 2 {	# generate a test
29	input = $3
30	test = sprintf("./echo '"'"'%s'"'"' | %s '"'"'%s/%s/ {print \"%d fails %s %s %s\"}'"'"'",
31		input, awk, neg, re, NR, re, op, input)
32	# printf(" %3d   %s %s %s:\n", NR, re, op, input)
33	# print "test is |" test "|"
34	system(test)
35	# system("bprint -c ../a.out")
36	nt++
37}
38END { print "	" nt, "tests" }
39' <<\!!!!
40	~	����
41		��������
42		������������
43		""
44����	~	����
45		b����
46		b����b
47	!~	""
48		���
49		xxxxx
50.	~	���
51		x���x
52		����
53	!~	""			
54.���	~	x���
55		xx���
56		x���x
57	!~	���
58		���x
59		""
60$	~	x
61		����
62		""
63.$	~	���
64		xx���
65		x���x
66	!~	""
67��$	~	��
68		b��
69		bbb��
70	!~	��b
71		x
72		""
73^	~	��
74		""
75		^
76^��$	~	��
77	!~	x��
78		��x
79		x��x
80		""
81^��.$	~	��x
82		����
83	!~	x��
84		������
85		��xy
86		""
87^$	~	""
88	!~	���
89		^
90^.���	~	������
91		���������
92	!~	���
93		""
94^.*���	~	���
95		������
96		���������������������
97	!~	""
98^.+���	~	������
99		���������������������
100	!~	""
101		���
102		������
103���*	~	""
104		���
105		������������
106		������
107		������������
108������*	~	���
109		���������
110		������
111	!~	������������
112		""
113\$	~	����$
114		$
115		$����
116		����$����
117	!~	""
118		����
119\.	~	.
120	!~	����
121		""
122x��+y	~	x��y
123		x����y
124		x������������y
125	!~	��y
126		xy
127		x��
128x��?y	~	xy
129		x��y
130	!~	x����y
131��?b?���?	~	""
132		x
133^a?b?���	~	���
134		a���
135		b���
136		ab���
137		���a
138	!~	""
139		ab
140		aba			
141[��-��]	~	��
142		a��b
143		xy��
144	!~	abc
145		��
146		""
147[^��-��]	~	��
148		a��b
149		xy��
150	!~	��
151		��
152		""
153[��-����-��]	~	��
154		��
155		��
156		��
157		��
158	!~	��
159		��
160��[[:lower:]]+	~	��a
161		��ab
162	!~	��
163		��X
164		��:
165		��[
166		��]
167���[0-9]+���	~	���0���
168		���23���
169		���12345���
170	!~	0���
171		������
172���[0-9]?���	~	������
173		���1���
174	!~	���23���
175���[[]���	~	���[���
176	!~	������
177		���[[]���
178		���]���
179���[[-]���	~	���[���
180		���-���
181	!~	������
182		���[[]���
183		���]���
184���[[-a]���	~	���[���
185		���a���
186		���]���
187	!~	������
188		���[[]���
189		���-���
190���[]-a]���	~	���]���
191		���a���
192	!~	������
193		���[���
194		���-���
195���[]]���	~	���]���
196	!~	������
197		���[]]���
198		���[���
199���[^[]���	~	���a���
200	!~	���[���
201���[-]���	~	���-���
202	!~	������
203		���+���
204���[^-]���	~	���+���
205	!~	���-���
206		������
207���[][]���	~	���[���
208		���]���
209	!~	������
210		���][���
211		���[]���
212���[z-a]���	~	������
213	!~	���
214		���
215		���a���
216		���z���
217		���-���
218���|���	~	���
219		���
220		������
221	!~	a
222		""
223^������|��������$	~	������
224		������d
225		a��������
226		��������
227	!~	x������
228		��������a
229^(������|��������)$	~	������
230		��������
231	!~	��������������
232		������x
233		c��������
234!!!!
235