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