brintos

brintos / llvm-project-archived public Read only

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