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