1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <regex>
10 
11 // template <class BidirectionalIterator, class Allocator, class charT,
12 //           class traits>
13 //   bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
14 //                    match_results<BidirectionalIterator, Allocator>& m,
15 //                    const basic_regex<charT, traits>& e,
16 //                    regex_constants::match_flag_type flags
17 //                                            = regex_constants::match_default);
18 
19 // TODO: investigation needed
20 // TODO(netbsd): incomplete support for locales
21 // XFAIL: linux-gnu, netbsd
22 // REQUIRES: locale.cs_CZ.ISO8859-2
23 
24 // REQUIRES: locale.cs_CZ.ISO8859-2
25 
26 #include <regex>
27 #include <cassert>
28 #include "test_macros.h"
29 #include "test_iterators.h"
30 
31 #include "platform_support.h" // locale name macros
32 
main(int,char **)33 int main(int, char**)
34 {
35     {
36         std::cmatch m;
37         const char s[] = "a";
38         assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk)));
39         assert(m.size() == 1);
40         assert(!m.empty());
41         assert(!m.prefix().matched);
42         assert(m.prefix().first == s);
43         assert(m.prefix().second == m[0].first);
44         assert(!m.suffix().matched);
45         assert(m.suffix().first == m[0].second);
46         assert(m.suffix().second == s+1);
47         assert(m.length(0) == 1);
48         assert(m.position(0) == 0);
49         assert(m.str(0) == "a");
50     }
51     {
52         std::cmatch m;
53         const char s[] = "ab";
54         assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
55         assert(m.size() == 1);
56         assert(!m.prefix().matched);
57         assert(m.prefix().first == s);
58         assert(m.prefix().second == m[0].first);
59         assert(!m.suffix().matched);
60         assert(m.suffix().first == m[0].second);
61         assert(m.suffix().second == s+2);
62         assert(m.length(0) == 2);
63         assert(m.position(0) == 0);
64         assert(m.str(0) == "ab");
65     }
66     {
67         std::cmatch m;
68         const char s[] = "ab";
69         assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::awk)));
70         assert(m.size() == 0);
71         assert(m.empty());
72     }
73     {
74         std::cmatch m;
75         const char s[] = "aab";
76         assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
77         assert(m.size() == 0);
78     }
79     {
80         std::cmatch m;
81         const char s[] = "aab";
82         assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk),
83                                             std::regex_constants::match_continuous));
84         assert(m.size() == 0);
85     }
86     {
87         std::cmatch m;
88         const char s[] = "abcd";
89         assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::awk)));
90         assert(m.size() == 0);
91     }
92     {
93         std::cmatch m;
94         const char s[] = "abbc";
95         assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::awk)));
96         assert(m.size() == 1);
97         assert(!m.prefix().matched);
98         assert(m.prefix().first == s);
99         assert(m.prefix().second == m[0].first);
100         assert(!m.suffix().matched);
101         assert(m.suffix().first == m[0].second);
102         assert(m.suffix().second == s+4);
103         assert(m.length(0) == 4);
104         assert(m.position(0) == 0);
105         assert(m.str(0) == s);
106     }
107     {
108         std::cmatch m;
109         const char s[] = "ababc";
110         assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
111         assert(m.size() == 2);
112         assert(!m.prefix().matched);
113         assert(m.prefix().first == s);
114         assert(m.prefix().second == m[0].first);
115         assert(!m.suffix().matched);
116         assert(m.suffix().first == m[0].second);
117         assert(m.suffix().second == s+5);
118         assert(m.length(0) == 5);
119         assert(m.position(0) == 0);
120         assert(m.str(0) == s);
121         assert(m.length(1) == 2);
122         assert(m.position(1) == 2);
123         assert(m.str(1) == "ab");
124     }
125     {
126         std::cmatch m;
127         const char s[] = "abcdefghijk";
128         assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
129                                  std::regex_constants::awk)));
130         assert(m.size() == 0);
131     }
132     {
133         std::cmatch m;
134         const char s[] = "abc";
135         assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
136         assert(m.size() == 1);
137         assert(!m.prefix().matched);
138         assert(m.prefix().first == s);
139         assert(m.prefix().second == m[0].first);
140         assert(!m.suffix().matched);
141         assert(m.suffix().first == m[0].second);
142         assert(m.suffix().second == s+3);
143         assert(m.length(0) == 3);
144         assert(m.position(0) == 0);
145         assert(m.str(0) == s);
146     }
147     {
148         std::cmatch m;
149         const char s[] = "abcd";
150         assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
151         assert(m.size() == 0);
152     }
153     {
154         std::cmatch m;
155         const char s[] = "aabc";
156         assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
157         assert(m.size() == 0);
158     }
159     {
160         std::cmatch m;
161         const char s[] = "abc";
162         assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
163         assert(m.size() == 1);
164         assert(!m.prefix().matched);
165         assert(m.prefix().first == s);
166         assert(m.prefix().second == m[0].first);
167         assert(!m.suffix().matched);
168         assert(m.suffix().first == m[0].second);
169         assert(m.suffix().second == s+3);
170         assert(m.length(0) == 3);
171         assert(m.position(0) == 0);
172         assert(m.str(0) == s);
173     }
174     {
175         std::cmatch m;
176         const char s[] = "efabc";
177         assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
178         assert(m.size() == 0);
179     }
180     {
181         std::cmatch m;
182         const char s[] = "efabcg";
183         assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
184         assert(m.size() == 0);
185     }
186     {
187         std::cmatch m;
188         const char s[] = "abc";
189         assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
190         assert(m.size() == 1);
191         assert(!m.prefix().matched);
192         assert(m.prefix().first == s);
193         assert(m.prefix().second == m[0].first);
194         assert(!m.suffix().matched);
195         assert(m.suffix().first == m[0].second);
196         assert(m.suffix().second == s+3);
197         assert(m.length(0) == 3);
198         assert(m.position(0) == 0);
199         assert(m.str(0) == s);
200     }
201     {
202         std::cmatch m;
203         const char s[] = "acc";
204         assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
205         assert(m.size() == 1);
206         assert(!m.prefix().matched);
207         assert(m.prefix().first == s);
208         assert(m.prefix().second == m[0].first);
209         assert(!m.suffix().matched);
210         assert(m.suffix().first == m[0].second);
211         assert(m.suffix().second == s+3);
212         assert(m.length(0) == 3);
213         assert(m.position(0) == 0);
214         assert(m.str(0) == s);
215     }
216     {
217         std::cmatch m;
218         const char s[] = "acc";
219         assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
220         assert(m.size() == 1);
221         assert(!m.prefix().matched);
222         assert(m.prefix().first == s);
223         assert(m.prefix().second == m[0].first);
224         assert(!m.suffix().matched);
225         assert(m.suffix().first == m[0].second);
226         assert(m.suffix().second == s+3);
227         assert(m.length(0) == 3);
228         assert(m.position(0) == 0);
229         assert(m.str(0) == s);
230     }
231     {
232         std::cmatch m;
233         const char s[] = "abcdef";
234         assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::awk)));
235         assert(m.size() == 2);
236         assert(!m.prefix().matched);
237         assert(m.prefix().first == s);
238         assert(m.prefix().second == m[0].first);
239         assert(!m.suffix().matched);
240         assert(m.suffix().first == m[0].second);
241         assert(m.suffix().second == s+6);
242         assert(m.length(0) == 6);
243         assert(m.position(0) == 0);
244         assert(m.str(0) == s);
245         assert(m.length(1) == 6);
246         assert(m.position(1) == 0);
247         assert(m.str(1) == s);
248     }
249     {
250         std::cmatch m;
251         const char s[] = "bc";
252         assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::awk)));
253         assert(m.size() == 0);
254     }
255     {
256         std::cmatch m;
257         const char s[] = "abbc";
258         assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
259         assert(m.size() == 0);
260     }
261     {
262         std::cmatch m;
263         const char s[] = "abbbc";
264         assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
265         assert(m.size() == 1);
266         assert(!m.prefix().matched);
267         assert(m.prefix().first == s);
268         assert(m.prefix().second == m[0].first);
269         assert(!m.suffix().matched);
270         assert(m.suffix().first == m[0].second);
271         assert(m.suffix().second == m[0].second);
272         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
273         assert(m.position(0) == 0);
274         assert(m.str(0) == s);
275     }
276     {
277         std::cmatch m;
278         const char s[] = "abbbbc";
279         assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
280         assert(m.size() == 1);
281         assert(!m.prefix().matched);
282         assert(m.prefix().first == s);
283         assert(m.prefix().second == m[0].first);
284         assert(!m.suffix().matched);
285         assert(m.suffix().first == m[0].second);
286         assert(m.suffix().second == m[0].second);
287         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
288         assert(m.position(0) == 0);
289         assert(m.str(0) == s);
290     }
291     {
292         std::cmatch m;
293         const char s[] = "abbbbbc";
294         assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
295         assert(m.size() == 1);
296         assert(!m.prefix().matched);
297         assert(m.prefix().first == s);
298         assert(m.prefix().second == m[0].first);
299         assert(!m.suffix().matched);
300         assert(m.suffix().first == m[0].second);
301         assert(m.suffix().second == m[0].second);
302         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
303         assert(m.position(0) == 0);
304         assert(m.str(0) == s);
305     }
306     {
307         std::cmatch m;
308         const char s[] = "adefc";
309         assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
310         assert(m.size() == 0);
311     }
312     {
313         std::cmatch m;
314         const char s[] = "abbbbbbc";
315         assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
316         assert(m.size() == 0);
317     }
318     {
319         std::cmatch m;
320         const char s[] = "adec";
321         assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
322         assert(m.size() == 0);
323     }
324     {
325         std::cmatch m;
326         const char s[] = "adefc";
327         assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
328         assert(m.size() == 1);
329         assert(!m.prefix().matched);
330         assert(m.prefix().first == s);
331         assert(m.prefix().second == m[0].first);
332         assert(!m.suffix().matched);
333         assert(m.suffix().first == m[0].second);
334         assert(m.suffix().second == m[0].second);
335         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
336         assert(m.position(0) == 0);
337         assert(m.str(0) == s);
338     }
339     {
340         std::cmatch m;
341         const char s[] = "adefgc";
342         assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
343         assert(m.size() == 1);
344         assert(!m.prefix().matched);
345         assert(m.prefix().first == s);
346         assert(m.prefix().second == m[0].first);
347         assert(!m.suffix().matched);
348         assert(m.suffix().first == m[0].second);
349         assert(m.suffix().second == m[0].second);
350         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
351         assert(m.position(0) == 0);
352         assert(m.str(0) == s);
353     }
354     {
355         std::cmatch m;
356         const char s[] = "adefghc";
357         assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
358         assert(m.size() == 1);
359         assert(!m.prefix().matched);
360         assert(m.prefix().first == s);
361         assert(m.prefix().second == m[0].first);
362         assert(!m.suffix().matched);
363         assert(m.suffix().first == m[0].second);
364         assert(m.suffix().second == m[0].second);
365         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
366         assert(m.position(0) == 0);
367         assert(m.str(0) == s);
368     }
369     {
370         std::cmatch m;
371         const char s[] = "adefghic";
372         assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
373         assert(m.size() == 0);
374     }
375     {
376         std::cmatch m;
377         const char s[] = "tournament";
378         assert(std::regex_match(s, m, std::regex("tour|to|tournament",
379                                               std::regex_constants::awk)));
380         assert(m.size() == 1);
381         assert(!m.prefix().matched);
382         assert(m.prefix().first == s);
383         assert(m.prefix().second == m[0].first);
384         assert(!m.suffix().matched);
385         assert(m.suffix().first == m[0].second);
386         assert(m.suffix().second == m[0].second);
387         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
388         assert(m.position(0) == 0);
389         assert(m.str(0) == s);
390     }
391     {
392         std::cmatch m;
393         const char s[] = "tournamenttotour";
394         assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
395                std::regex_constants::awk | std::regex_constants::nosubs)));
396         assert(m.size() == 1);
397         assert(!m.prefix().matched);
398         assert(m.prefix().first == s);
399         assert(m.prefix().second == m[0].first);
400         assert(!m.suffix().matched);
401         assert(m.suffix().first == m[0].second);
402         assert(m.suffix().second == m[0].second);
403         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
404         assert(m.position(0) == 0);
405         assert(m.str(0) == s);
406     }
407     {
408         std::cmatch m;
409         const char s[] = "ttotour";
410         assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
411                                               std::regex_constants::awk)));
412         assert(m.size() == 2);
413         assert(!m.prefix().matched);
414         assert(m.prefix().first == s);
415         assert(m.prefix().second == m[0].first);
416         assert(!m.suffix().matched);
417         assert(m.suffix().first == m[0].second);
418         assert(m.suffix().second == m[0].second);
419         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
420         assert(m.position(0) == 0);
421         assert(m.str(0) == s);
422         assert(m.length(1) == 4);
423         assert(m.position(1) == 3);
424         assert(m.str(1) == "tour");
425     }
426     {
427         std::cmatch m;
428         const char s[] = "-ab,ab-";
429         assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
430         assert(m.size() == 0);
431     }
432     {
433         std::cmatch m;
434         const char s[] = "-ab,ab-";
435         assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
436         assert(m.size() == 1);
437         assert(!m.prefix().matched);
438         assert(m.prefix().first == s);
439         assert(m.prefix().second == m[0].first);
440         assert(!m.suffix().matched);
441         assert(m.suffix().first == m[0].second);
442         assert(m.suffix().second == m[0].second);
443         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
444         assert(m.position(0) == 0);
445         assert(m.str(0) == s);
446     }
447     {
448         std::cmatch m;
449         const char s[] = "a";
450         assert(std::regex_match(s, m, std::regex("^[a]$",
451                                                  std::regex_constants::awk)));
452         assert(m.size() == 1);
453         assert(!m.prefix().matched);
454         assert(m.prefix().first == s);
455         assert(m.prefix().second == m[0].first);
456         assert(!m.suffix().matched);
457         assert(m.suffix().first == m[0].second);
458         assert(m.suffix().second == m[0].second);
459         assert(m.length(0) == 1);
460         assert(m.position(0) == 0);
461         assert(m.str(0) == "a");
462     }
463     {
464         std::cmatch m;
465         const char s[] = "a";
466         assert(std::regex_match(s, m, std::regex("^[ab]$",
467                                                  std::regex_constants::awk)));
468         assert(m.size() == 1);
469         assert(!m.prefix().matched);
470         assert(m.prefix().first == s);
471         assert(m.prefix().second == m[0].first);
472         assert(!m.suffix().matched);
473         assert(m.suffix().first == m[0].second);
474         assert(m.suffix().second == m[0].second);
475         assert(m.length(0) == 1);
476         assert(m.position(0) == 0);
477         assert(m.str(0) == "a");
478     }
479     {
480         std::cmatch m;
481         const char s[] = "c";
482         assert(std::regex_match(s, m, std::regex("^[a-f]$",
483                                                  std::regex_constants::awk)));
484         assert(m.size() == 1);
485         assert(!m.prefix().matched);
486         assert(m.prefix().first == s);
487         assert(m.prefix().second == m[0].first);
488         assert(!m.suffix().matched);
489         assert(m.suffix().first == m[0].second);
490         assert(m.suffix().second == m[0].second);
491         assert(m.length(0) == 1);
492         assert(m.position(0) == 0);
493         assert(m.str(0) == s);
494     }
495     {
496         std::cmatch m;
497         const char s[] = "g";
498         assert(!std::regex_match(s, m, std::regex("^[a-f]$",
499                                                  std::regex_constants::awk)));
500         assert(m.size() == 0);
501     }
502     {
503         std::cmatch m;
504         const char s[] = "Iraqi";
505         assert(!std::regex_match(s, m, std::regex("q[^u]",
506                                                  std::regex_constants::awk)));
507         assert(m.size() == 0);
508     }
509     {
510         std::cmatch m;
511         const char s[] = "Iraq";
512         assert(!std::regex_match(s, m, std::regex("q[^u]",
513                                                  std::regex_constants::awk)));
514         assert(m.size() == 0);
515     }
516     {
517         std::cmatch m;
518         const char s[] = "AmB";
519         assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
520                                                  std::regex_constants::awk)));
521         assert(m.size() == 1);
522         assert(!m.prefix().matched);
523         assert(m.prefix().first == s);
524         assert(m.prefix().second == m[0].first);
525         assert(!m.suffix().matched);
526         assert(m.suffix().first == m[0].second);
527         assert(m.suffix().second == m[0].second);
528         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
529         assert(m.position(0) == 0);
530         assert(m.str(0) == s);
531     }
532     {
533         std::cmatch m;
534         const char s[] = "AMB";
535         assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
536                                                  std::regex_constants::awk)));
537         assert(m.size() == 0);
538     }
539     {
540         std::cmatch m;
541         const char s[] = "AMB";
542         assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
543                                                  std::regex_constants::awk)));
544         assert(m.size() == 1);
545         assert(!m.prefix().matched);
546         assert(m.prefix().first == s);
547         assert(m.prefix().second == m[0].first);
548         assert(!m.suffix().matched);
549         assert(m.suffix().first == m[0].second);
550         assert(m.suffix().second == m[0].second);
551         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
552         assert(m.position(0) == 0);
553         assert(m.str(0) == s);
554     }
555     {
556         std::cmatch m;
557         const char s[] = "AmB";
558         assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
559                                                  std::regex_constants::awk)));
560         assert(m.size() == 0);
561     }
562     {
563         std::cmatch m;
564         const char s[] = "A5B";
565         assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
566                                                  std::regex_constants::awk)));
567         assert(m.size() == 0);
568     }
569     {
570         std::cmatch m;
571         const char s[] = "A?B";
572         assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
573                                                  std::regex_constants::awk)));
574         assert(m.size() == 1);
575         assert(!m.prefix().matched);
576         assert(m.prefix().first == s);
577         assert(m.prefix().second == m[0].first);
578         assert(!m.suffix().matched);
579         assert(m.suffix().first == m[0].second);
580         assert(m.suffix().second == m[0].second);
581         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
582         assert(m.position(0) == 0);
583         assert(m.str(0) == s);
584     }
585     {
586         std::cmatch m;
587         const char s[] = "-";
588         assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
589                                                  std::regex_constants::awk)));
590         assert(m.size() == 1);
591         assert(!m.prefix().matched);
592         assert(m.prefix().first == s);
593         assert(m.prefix().second == m[0].first);
594         assert(!m.suffix().matched);
595         assert(m.suffix().first == m[0].second);
596         assert(m.suffix().second == m[0].second);
597         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
598         assert(m.position(0) == 0);
599         assert(m.str(0) == s);
600     }
601     {
602         std::cmatch m;
603         const char s[] = "z";
604         assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
605                                                  std::regex_constants::awk)));
606         assert(m.size() == 1);
607         assert(!m.prefix().matched);
608         assert(m.prefix().first == s);
609         assert(m.prefix().second == m[0].first);
610         assert(!m.suffix().matched);
611         assert(m.suffix().first == m[0].second);
612         assert(m.suffix().second == m[0].second);
613         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
614         assert(m.position(0) == 0);
615         assert(m.str(0) == s);
616     }
617     {
618         std::cmatch m;
619         const char s[] = "m";
620         assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
621                                                  std::regex_constants::awk)));
622         assert(m.size() == 0);
623     }
624 
625     // FIXME: check if locales are available?
626 
627     std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
628     {
629         std::cmatch m;
630         const char s[] = "m";
631         assert(std::regex_match(s, m,
632                       std::regex("[a[=M=]z]", std::regex_constants::awk)));
633         assert(m.size() == 1);
634         assert(!m.prefix().matched);
635         assert(m.prefix().first == s);
636         assert(m.prefix().second == m[0].first);
637         assert(!m.suffix().matched);
638         assert(m.suffix().first == m[0].second);
639         assert(m.suffix().second == m[0].second);
640         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
641         assert(m.position(0) == 0);
642         assert(m.str(0) == s);
643     }
644     {
645         std::cmatch m;
646         const char s[] = "Ch";
647         assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
648                    std::regex_constants::awk | std::regex_constants::icase)));
649         assert(m.size() == 1);
650         assert(!m.prefix().matched);
651         assert(m.prefix().first == s);
652         assert(m.prefix().second == m[0].first);
653         assert(!m.suffix().matched);
654         assert(m.suffix().first == m[0].second);
655         assert(m.suffix().second == m[0].second);
656         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
657         assert(m.position(0) == 0);
658         assert(m.str(0) == s);
659     }
660     std::locale::global(std::locale("C"));
661     {
662         std::cmatch m;
663         const char s[] = "m";
664         assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
665                                                  std::regex_constants::awk)));
666         assert(m.size() == 0);
667     }
668     {
669         std::cmatch m;
670         const char s[] = "01a45cef9";
671         assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
672                                                  std::regex_constants::awk)));
673         assert(m.size() == 0);
674     }
675     {
676         std::cmatch m;
677         const char s[] = "01a45cef9";
678         assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
679                                                  std::regex_constants::awk)));
680         assert(m.size() == 0);
681     }
682     {
683         const char r[] = "^[-+]?[0-9]+[CF]$";
684         std::ptrdiff_t sr = std::char_traits<char>::length(r);
685         typedef forward_iterator<const char*> FI;
686         typedef bidirectional_iterator<const char*> BI;
687         std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
688         std::match_results<BI> m;
689         const char s[] = "-40C";
690         std::ptrdiff_t ss = std::char_traits<char>::length(s);
691         assert(std::regex_match(BI(s), BI(s+ss), m, regex));
692         assert(m.size() == 1);
693         assert(!m.prefix().matched);
694         assert(m.prefix().first == BI(s));
695         assert(m.prefix().second == m[0].first);
696         assert(!m.suffix().matched);
697         assert(m.suffix().first == m[0].second);
698         assert(m.suffix().second == m[0].second);
699         assert((size_t)m.length(0) == 4);
700         assert(m.position(0) == 0);
701         assert(m.str(0) == s);
702     }
703     {
704         std::cmatch m;
705         const char s[] = "\n\n\n";
706         assert(std::regex_match(s, m, std::regex("[\\n]+",
707                                                  std::regex_constants::awk)));
708         assert(m.size() == 1);
709         assert(!m.prefix().matched);
710         assert(m.prefix().first == s);
711         assert(m.prefix().second == m[0].first);
712         assert(!m.suffix().matched);
713         assert(m.suffix().first == m[0].second);
714         assert(m.suffix().second == s + std::char_traits<char>::length(s));
715         assert((size_t)m.length(0) == std::char_traits<char>::length(s));
716         assert(m.position(0) == 0);
717         assert(m.str(0) == s);
718     }
719     {
720         std::wcmatch m;
721         const wchar_t s[] = L"a";
722         assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::awk)));
723         assert(m.size() == 1);
724         assert(!m.empty());
725         assert(!m.prefix().matched);
726         assert(m.prefix().first == s);
727         assert(m.prefix().second == m[0].first);
728         assert(!m.suffix().matched);
729         assert(m.suffix().first == m[0].second);
730         assert(m.suffix().second == s+1);
731         assert((size_t)m.length(0) == 1);
732         assert(m.position(0) == 0);
733         assert(m.str(0) == L"a");
734     }
735     {
736         std::wcmatch m;
737         const wchar_t s[] = L"ab";
738         assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
739         assert(m.size() == 1);
740         assert(!m.prefix().matched);
741         assert(m.prefix().first == s);
742         assert(m.prefix().second == m[0].first);
743         assert(!m.suffix().matched);
744         assert(m.suffix().first == m[0].second);
745         assert(m.suffix().second == s+2);
746         assert((size_t)m.length(0) == 2);
747         assert(m.position(0) == 0);
748         assert(m.str(0) == L"ab");
749     }
750     {
751         std::wcmatch m;
752         const wchar_t s[] = L"ab";
753         assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::awk)));
754         assert(m.size() == 0);
755         assert(m.empty());
756     }
757     {
758         std::wcmatch m;
759         const wchar_t s[] = L"aab";
760         assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
761         assert(m.size() == 0);
762     }
763     {
764         std::wcmatch m;
765         const wchar_t s[] = L"aab";
766         assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk),
767                                             std::regex_constants::match_continuous));
768         assert(m.size() == 0);
769     }
770     {
771         std::wcmatch m;
772         const wchar_t s[] = L"abcd";
773         assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::awk)));
774         assert(m.size() == 0);
775     }
776     {
777         std::wcmatch m;
778         const wchar_t s[] = L"abbc";
779         assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
780         assert(m.size() == 1);
781         assert(!m.prefix().matched);
782         assert(m.prefix().first == s);
783         assert(m.prefix().second == m[0].first);
784         assert(!m.suffix().matched);
785         assert(m.suffix().first == m[0].second);
786         assert(m.suffix().second == s+4);
787         assert(m.length(0) == 4);
788         assert(m.position(0) == 0);
789         assert(m.str(0) == s);
790     }
791     {
792         std::wcmatch m;
793         const wchar_t s[] = L"ababc";
794         assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
795         assert(m.size() == 2);
796         assert(!m.prefix().matched);
797         assert(m.prefix().first == s);
798         assert(m.prefix().second == m[0].first);
799         assert(!m.suffix().matched);
800         assert(m.suffix().first == m[0].second);
801         assert(m.suffix().second == s+5);
802         assert(m.length(0) == 5);
803         assert(m.position(0) == 0);
804         assert(m.str(0) == s);
805         assert(m.length(1) == 2);
806         assert(m.position(1) == 2);
807         assert(m.str(1) == L"ab");
808     }
809     {
810         std::wcmatch m;
811         const wchar_t s[] = L"abcdefghijk";
812         assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
813                                  std::regex_constants::awk)));
814         assert(m.size() == 0);
815     }
816     {
817         std::wcmatch m;
818         const wchar_t s[] = L"abc";
819         assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
820         assert(m.size() == 1);
821         assert(!m.prefix().matched);
822         assert(m.prefix().first == s);
823         assert(m.prefix().second == m[0].first);
824         assert(!m.suffix().matched);
825         assert(m.suffix().first == m[0].second);
826         assert(m.suffix().second == s+3);
827         assert(m.length(0) == 3);
828         assert(m.position(0) == 0);
829         assert(m.str(0) == s);
830     }
831     {
832         std::wcmatch m;
833         const wchar_t s[] = L"abcd";
834         assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
835         assert(m.size() == 0);
836     }
837     {
838         std::wcmatch m;
839         const wchar_t s[] = L"aabc";
840         assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
841         assert(m.size() == 0);
842     }
843     {
844         std::wcmatch m;
845         const wchar_t s[] = L"abc";
846         assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
847         assert(m.size() == 1);
848         assert(!m.prefix().matched);
849         assert(m.prefix().first == s);
850         assert(m.prefix().second == m[0].first);
851         assert(!m.suffix().matched);
852         assert(m.suffix().first == m[0].second);
853         assert(m.suffix().second == s+3);
854         assert(m.length(0) == 3);
855         assert(m.position(0) == 0);
856         assert(m.str(0) == s);
857     }
858     {
859         std::wcmatch m;
860         const wchar_t s[] = L"efabc";
861         assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
862         assert(m.size() == 0);
863     }
864     {
865         std::wcmatch m;
866         const wchar_t s[] = L"efabcg";
867         assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
868         assert(m.size() == 0);
869     }
870     {
871         std::wcmatch m;
872         const wchar_t s[] = L"abc";
873         assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
874         assert(m.size() == 1);
875         assert(!m.prefix().matched);
876         assert(m.prefix().first == s);
877         assert(m.prefix().second == m[0].first);
878         assert(!m.suffix().matched);
879         assert(m.suffix().first == m[0].second);
880         assert(m.suffix().second == s+3);
881         assert(m.length(0) == 3);
882         assert(m.position(0) == 0);
883         assert(m.str(0) == s);
884     }
885     {
886         std::wcmatch m;
887         const wchar_t s[] = L"acc";
888         assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
889         assert(m.size() == 1);
890         assert(!m.prefix().matched);
891         assert(m.prefix().first == s);
892         assert(m.prefix().second == m[0].first);
893         assert(!m.suffix().matched);
894         assert(m.suffix().first == m[0].second);
895         assert(m.suffix().second == s+3);
896         assert(m.length(0) == 3);
897         assert(m.position(0) == 0);
898         assert(m.str(0) == s);
899     }
900     {
901         std::wcmatch m;
902         const wchar_t s[] = L"acc";
903         assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
904         assert(m.size() == 1);
905         assert(!m.prefix().matched);
906         assert(m.prefix().first == s);
907         assert(m.prefix().second == m[0].first);
908         assert(!m.suffix().matched);
909         assert(m.suffix().first == m[0].second);
910         assert(m.suffix().second == s+3);
911         assert(m.length(0) == 3);
912         assert(m.position(0) == 0);
913         assert(m.str(0) == s);
914     }
915     {
916         std::wcmatch m;
917         const wchar_t s[] = L"abcdef";
918         assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
919         assert(m.size() == 2);
920         assert(!m.prefix().matched);
921         assert(m.prefix().first == s);
922         assert(m.prefix().second == m[0].first);
923         assert(!m.suffix().matched);
924         assert(m.suffix().first == m[0].second);
925         assert(m.suffix().second == s+6);
926         assert(m.length(0) == 6);
927         assert(m.position(0) == 0);
928         assert(m.str(0) == s);
929         assert(m.length(1) == 6);
930         assert(m.position(1) == 0);
931         assert(m.str(1) == s);
932     }
933     {
934         std::wcmatch m;
935         const wchar_t s[] = L"bc";
936         assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
937         assert(m.size() == 0);
938     }
939     {
940         std::wcmatch m;
941         const wchar_t s[] = L"abbc";
942         assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
943         assert(m.size() == 0);
944     }
945     {
946         std::wcmatch m;
947         const wchar_t s[] = L"abbbc";
948         assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
949         assert(m.size() == 1);
950         assert(!m.prefix().matched);
951         assert(m.prefix().first == s);
952         assert(m.prefix().second == m[0].first);
953         assert(!m.suffix().matched);
954         assert(m.suffix().first == m[0].second);
955         assert(m.suffix().second == m[0].second);
956         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
957         assert(m.position(0) == 0);
958         assert(m.str(0) == s);
959     }
960     {
961         std::wcmatch m;
962         const wchar_t s[] = L"abbbbc";
963         assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
964         assert(m.size() == 1);
965         assert(!m.prefix().matched);
966         assert(m.prefix().first == s);
967         assert(m.prefix().second == m[0].first);
968         assert(!m.suffix().matched);
969         assert(m.suffix().first == m[0].second);
970         assert(m.suffix().second == m[0].second);
971         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
972         assert(m.position(0) == 0);
973         assert(m.str(0) == s);
974     }
975     {
976         std::wcmatch m;
977         const wchar_t s[] = L"abbbbbc";
978         assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
979         assert(m.size() == 1);
980         assert(!m.prefix().matched);
981         assert(m.prefix().first == s);
982         assert(m.prefix().second == m[0].first);
983         assert(!m.suffix().matched);
984         assert(m.suffix().first == m[0].second);
985         assert(m.suffix().second == m[0].second);
986         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
987         assert(m.position(0) == 0);
988         assert(m.str(0) == s);
989     }
990     {
991         std::wcmatch m;
992         const wchar_t s[] = L"adefc";
993         assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
994         assert(m.size() == 0);
995     }
996     {
997         std::wcmatch m;
998         const wchar_t s[] = L"abbbbbbc";
999         assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
1000         assert(m.size() == 0);
1001     }
1002     {
1003         std::wcmatch m;
1004         const wchar_t s[] = L"adec";
1005         assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
1006         assert(m.size() == 0);
1007     }
1008     {
1009         std::wcmatch m;
1010         const wchar_t s[] = L"adefc";
1011         assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
1012         assert(m.size() == 1);
1013         assert(!m.prefix().matched);
1014         assert(m.prefix().first == s);
1015         assert(m.prefix().second == m[0].first);
1016         assert(!m.suffix().matched);
1017         assert(m.suffix().first == m[0].second);
1018         assert(m.suffix().second == m[0].second);
1019         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1020         assert(m.position(0) == 0);
1021         assert(m.str(0) == s);
1022     }
1023     {
1024         std::wcmatch m;
1025         const wchar_t s[] = L"adefgc";
1026         assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
1027         assert(m.size() == 1);
1028         assert(!m.prefix().matched);
1029         assert(m.prefix().first == s);
1030         assert(m.prefix().second == m[0].first);
1031         assert(!m.suffix().matched);
1032         assert(m.suffix().first == m[0].second);
1033         assert(m.suffix().second == m[0].second);
1034         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1035         assert(m.position(0) == 0);
1036         assert(m.str(0) == s);
1037     }
1038     {
1039         std::wcmatch m;
1040         const wchar_t s[] = L"adefghc";
1041         assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
1042         assert(m.size() == 1);
1043         assert(!m.prefix().matched);
1044         assert(m.prefix().first == s);
1045         assert(m.prefix().second == m[0].first);
1046         assert(!m.suffix().matched);
1047         assert(m.suffix().first == m[0].second);
1048         assert(m.suffix().second == m[0].second);
1049         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1050         assert(m.position(0) == 0);
1051         assert(m.str(0) == s);
1052     }
1053     {
1054         std::wcmatch m;
1055         const wchar_t s[] = L"adefghic";
1056         assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
1057         assert(m.size() == 0);
1058     }
1059     {
1060         std::wcmatch m;
1061         const wchar_t s[] = L"tournament";
1062         assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
1063                                               std::regex_constants::awk)));
1064         assert(m.size() == 1);
1065         assert(!m.prefix().matched);
1066         assert(m.prefix().first == s);
1067         assert(m.prefix().second == m[0].first);
1068         assert(!m.suffix().matched);
1069         assert(m.suffix().first == m[0].second);
1070         assert(m.suffix().second == m[0].second);
1071         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1072         assert(m.position(0) == 0);
1073         assert(m.str(0) == s);
1074     }
1075     {
1076         std::wcmatch m;
1077         const wchar_t s[] = L"tournamenttotour";
1078         assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
1079                std::regex_constants::awk | std::regex_constants::nosubs)));
1080         assert(m.size() == 1);
1081         assert(!m.prefix().matched);
1082         assert(m.prefix().first == s);
1083         assert(m.prefix().second == m[0].first);
1084         assert(!m.suffix().matched);
1085         assert(m.suffix().first == m[0].second);
1086         assert(m.suffix().second == m[0].second);
1087         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1088         assert(m.position(0) == 0);
1089         assert(m.str(0) == s);
1090     }
1091     {
1092         std::wcmatch m;
1093         const wchar_t s[] = L"ttotour";
1094         assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
1095                                               std::regex_constants::awk)));
1096         assert(m.size() == 2);
1097         assert(!m.prefix().matched);
1098         assert(m.prefix().first == s);
1099         assert(m.prefix().second == m[0].first);
1100         assert(!m.suffix().matched);
1101         assert(m.suffix().first == m[0].second);
1102         assert(m.suffix().second == m[0].second);
1103         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1104         assert(m.position(0) == 0);
1105         assert(m.str(0) == s);
1106         assert(m.length(1) == 4);
1107         assert(m.position(1) == 3);
1108         assert(m.str(1) == L"tour");
1109     }
1110     {
1111         std::wcmatch m;
1112         const wchar_t s[] = L"-ab,ab-";
1113         assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
1114         assert(m.size() == 0);
1115     }
1116     {
1117         std::wcmatch m;
1118         const wchar_t s[] = L"-ab,ab-";
1119         assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
1120         assert(m.size() == 1);
1121         assert(!m.prefix().matched);
1122         assert(m.prefix().first == s);
1123         assert(m.prefix().second == m[0].first);
1124         assert(!m.suffix().matched);
1125         assert(m.suffix().first == m[0].second);
1126         assert(m.suffix().second == m[0].second);
1127         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1128         assert(m.position(0) == 0);
1129         assert(m.str(0) == s);
1130     }
1131     {
1132         std::wcmatch m;
1133         const wchar_t s[] = L"a";
1134         assert(std::regex_match(s, m, std::wregex(L"^[a]$",
1135                                                  std::regex_constants::awk)));
1136         assert(m.size() == 1);
1137         assert(!m.prefix().matched);
1138         assert(m.prefix().first == s);
1139         assert(m.prefix().second == m[0].first);
1140         assert(!m.suffix().matched);
1141         assert(m.suffix().first == m[0].second);
1142         assert(m.suffix().second == m[0].second);
1143         assert(m.length(0) == 1);
1144         assert(m.position(0) == 0);
1145         assert(m.str(0) == L"a");
1146     }
1147     {
1148         std::wcmatch m;
1149         const wchar_t s[] = L"a";
1150         assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
1151                                                  std::regex_constants::awk)));
1152         assert(m.size() == 1);
1153         assert(!m.prefix().matched);
1154         assert(m.prefix().first == s);
1155         assert(m.prefix().second == m[0].first);
1156         assert(!m.suffix().matched);
1157         assert(m.suffix().first == m[0].second);
1158         assert(m.suffix().second == m[0].second);
1159         assert(m.length(0) == 1);
1160         assert(m.position(0) == 0);
1161         assert(m.str(0) == L"a");
1162     }
1163     {
1164         std::wcmatch m;
1165         const wchar_t s[] = L"c";
1166         assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
1167                                                  std::regex_constants::awk)));
1168         assert(m.size() == 1);
1169         assert(!m.prefix().matched);
1170         assert(m.prefix().first == s);
1171         assert(m.prefix().second == m[0].first);
1172         assert(!m.suffix().matched);
1173         assert(m.suffix().first == m[0].second);
1174         assert(m.suffix().second == m[0].second);
1175         assert(m.length(0) == 1);
1176         assert(m.position(0) == 0);
1177         assert(m.str(0) == s);
1178     }
1179     {
1180         std::wcmatch m;
1181         const wchar_t s[] = L"g";
1182         assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
1183                                                  std::regex_constants::awk)));
1184         assert(m.size() == 0);
1185     }
1186     {
1187         std::wcmatch m;
1188         const wchar_t s[] = L"Iraqi";
1189         assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
1190                                                  std::regex_constants::awk)));
1191         assert(m.size() == 0);
1192     }
1193     {
1194         std::wcmatch m;
1195         const wchar_t s[] = L"Iraq";
1196         assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
1197                                                  std::regex_constants::awk)));
1198         assert(m.size() == 0);
1199     }
1200     {
1201         std::wcmatch m;
1202         const wchar_t s[] = L"AmB";
1203         assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
1204                                                  std::regex_constants::awk)));
1205         assert(m.size() == 1);
1206         assert(!m.prefix().matched);
1207         assert(m.prefix().first == s);
1208         assert(m.prefix().second == m[0].first);
1209         assert(!m.suffix().matched);
1210         assert(m.suffix().first == m[0].second);
1211         assert(m.suffix().second == m[0].second);
1212         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1213         assert(m.position(0) == 0);
1214         assert(m.str(0) == s);
1215     }
1216     {
1217         std::wcmatch m;
1218         const wchar_t s[] = L"AMB";
1219         assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
1220                                                  std::regex_constants::awk)));
1221         assert(m.size() == 0);
1222     }
1223     {
1224         std::wcmatch m;
1225         const wchar_t s[] = L"AMB";
1226         assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
1227                                                  std::regex_constants::awk)));
1228         assert(m.size() == 1);
1229         assert(!m.prefix().matched);
1230         assert(m.prefix().first == s);
1231         assert(m.prefix().second == m[0].first);
1232         assert(!m.suffix().matched);
1233         assert(m.suffix().first == m[0].second);
1234         assert(m.suffix().second == m[0].second);
1235         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1236         assert(m.position(0) == 0);
1237         assert(m.str(0) == s);
1238     }
1239     {
1240         std::wcmatch m;
1241         const wchar_t s[] = L"AmB";
1242         assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
1243                                                  std::regex_constants::awk)));
1244         assert(m.size() == 0);
1245     }
1246     {
1247         std::wcmatch m;
1248         const wchar_t s[] = L"A5B";
1249         assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
1250                                                  std::regex_constants::awk)));
1251         assert(m.size() == 0);
1252     }
1253     {
1254         std::wcmatch m;
1255         const wchar_t s[] = L"A?B";
1256         assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
1257                                                  std::regex_constants::awk)));
1258         assert(m.size() == 1);
1259         assert(!m.prefix().matched);
1260         assert(m.prefix().first == s);
1261         assert(m.prefix().second == m[0].first);
1262         assert(!m.suffix().matched);
1263         assert(m.suffix().first == m[0].second);
1264         assert(m.suffix().second == m[0].second);
1265         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1266         assert(m.position(0) == 0);
1267         assert(m.str(0) == s);
1268     }
1269     {
1270         std::wcmatch m;
1271         const wchar_t s[] = L"-";
1272         assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
1273                                                  std::regex_constants::awk)));
1274         assert(m.size() == 1);
1275         assert(!m.prefix().matched);
1276         assert(m.prefix().first == s);
1277         assert(m.prefix().second == m[0].first);
1278         assert(!m.suffix().matched);
1279         assert(m.suffix().first == m[0].second);
1280         assert(m.suffix().second == m[0].second);
1281         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1282         assert(m.position(0) == 0);
1283         assert(m.str(0) == s);
1284     }
1285     {
1286         std::wcmatch m;
1287         const wchar_t s[] = L"z";
1288         assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
1289                                                  std::regex_constants::awk)));
1290         assert(m.size() == 1);
1291         assert(!m.prefix().matched);
1292         assert(m.prefix().first == s);
1293         assert(m.prefix().second == m[0].first);
1294         assert(!m.suffix().matched);
1295         assert(m.suffix().first == m[0].second);
1296         assert(m.suffix().second == m[0].second);
1297         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1298         assert(m.position(0) == 0);
1299         assert(m.str(0) == s);
1300     }
1301     {
1302         std::wcmatch m;
1303         const wchar_t s[] = L"m";
1304         assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
1305                                                  std::regex_constants::awk)));
1306         assert(m.size() == 0);
1307     }
1308     std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
1309     {
1310         std::wcmatch m;
1311         const wchar_t s[] = L"m";
1312         assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
1313                                                  std::regex_constants::awk)));
1314         assert(m.size() == 1);
1315         assert(!m.prefix().matched);
1316         assert(m.prefix().first == s);
1317         assert(m.prefix().second == m[0].first);
1318         assert(!m.suffix().matched);
1319         assert(m.suffix().first == m[0].second);
1320         assert(m.suffix().second == m[0].second);
1321         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1322         assert(m.position(0) == 0);
1323         assert(m.str(0) == s);
1324     }
1325     {
1326         std::wcmatch m;
1327         const wchar_t s[] = L"Ch";
1328         assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
1329                    std::regex_constants::awk | std::regex_constants::icase)));
1330         assert(m.size() == 1);
1331         assert(!m.prefix().matched);
1332         assert(m.prefix().first == s);
1333         assert(m.prefix().second == m[0].first);
1334         assert(!m.suffix().matched);
1335         assert(m.suffix().first == m[0].second);
1336         assert(m.suffix().second == m[0].second);
1337         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1338         assert(m.position(0) == 0);
1339         assert(m.str(0) == s);
1340     }
1341     std::locale::global(std::locale("C"));
1342     {
1343         std::wcmatch m;
1344         const wchar_t s[] = L"m";
1345         assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
1346                                                  std::regex_constants::awk)));
1347         assert(m.size() == 0);
1348     }
1349     {
1350         std::wcmatch m;
1351         const wchar_t s[] = L"01a45cef9";
1352         assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
1353                                                  std::regex_constants::awk)));
1354         assert(m.size() == 0);
1355     }
1356     {
1357         std::wcmatch m;
1358         const wchar_t s[] = L"01a45cef9";
1359         assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
1360                                                  std::regex_constants::awk)));
1361         assert(m.size() == 0);
1362     }
1363     {
1364         const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
1365         std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
1366         typedef forward_iterator<const wchar_t*> FI;
1367         typedef bidirectional_iterator<const wchar_t*> BI;
1368         std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
1369         std::match_results<BI> m;
1370         const wchar_t s[] = L"-40C";
1371         std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
1372         assert(std::regex_match(BI(s), BI(s+ss), m, regex));
1373         assert(m.size() == 1);
1374         assert(!m.prefix().matched);
1375         assert(m.prefix().first == BI(s));
1376         assert(m.prefix().second == m[0].first);
1377         assert(!m.suffix().matched);
1378         assert(m.suffix().first == m[0].second);
1379         assert(m.suffix().second == m[0].second);
1380         assert(m.length(0) == 4);
1381         assert(m.position(0) == 0);
1382         assert(m.str(0) == s);
1383     }
1384     {
1385         std::wcmatch m;
1386         const wchar_t s[] = L"\n\n\n";
1387         assert(std::regex_match(s, m, std::wregex(L"[\\n]+",
1388                                                  std::regex_constants::awk)));
1389         assert(m.size() == 1);
1390         assert(!m.prefix().matched);
1391         assert(m.prefix().first == s);
1392         assert(m.prefix().second == m[0].first);
1393         assert(!m.suffix().matched);
1394         assert(m.suffix().first == m[0].second);
1395         assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
1396         assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
1397         assert(m.position(0) == 0);
1398         assert(m.str(0) == s);
1399     }
1400     return 0;
1401 }
1402