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