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