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