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