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