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