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