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