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