brintos

brintos / llvm-project-archived public Read only

0
0
Text · 48.3 KiB · 0184a38 Raw
1384 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 10// <regex>11 12// template <class BidirectionalIterator, class Allocator, class charT, class traits>13//     bool14//     regex_match(BidirectionalIterator first, BidirectionalIterator last,15//                  match_results<BidirectionalIterator, Allocator>& m,16//                  const basic_regex<charT, traits>& e,17//                  regex_constants::match_flag_type flags = regex_constants::match_default);18 19#include <regex>20#include <cassert>21#include "test_macros.h"22#include "test_iterators.h"23 24int main(int, char**)25{26    {27        std::cmatch m;28        const char s[] = "a";29        assert(std::regex_match(s, m, std::regex("a")));30        assert(m.size() == 1);31        assert(!m.empty());32        assert(!m.prefix().matched);33        assert(m.prefix().first == s);34        assert(m.prefix().second == m[0].first);35        assert(!m.suffix().matched);36        assert(m.suffix().first == m[0].second);37        assert(m.suffix().second == s+1);38        assert(m.length(0) == 1);39        assert(m.position(0) == 0);40        assert(m.str(0) == "a");41    }42    {43        std::cmatch m;44        const char s[] = "ab";45        assert(std::regex_match(s, m, std::regex("ab")));46        assert(m.size() == 1);47        assert(!m.prefix().matched);48        assert(m.prefix().first == s);49        assert(m.prefix().second == m[0].first);50        assert(!m.suffix().matched);51        assert(m.suffix().first == m[0].second);52        assert(m.suffix().second == s+2);53        assert(m.length(0) == 2);54        assert(m.position(0) == 0);55        assert(m.str(0) == "ab");56    }57    {58        std::cmatch m;59        const char s[] = "ab";60        assert(!std::regex_match(s, m, std::regex("ba")));61        assert(m.size() == 0);62        assert(m.empty());63    }64    {65        std::cmatch m;66        const char s[] = "aab";67        assert(!std::regex_match(s, m, std::regex("ab")));68        assert(m.size() == 0);69    }70    {71        std::cmatch m;72        const char s[] = "aab";73        assert(!std::regex_match(s, m, std::regex("ab"),74                                            std::regex_constants::match_continuous));75        assert(m.size() == 0);76    }77    {78        std::cmatch m;79        const char s[] = "abcd";80        assert(!std::regex_match(s, m, std::regex("bc")));81        assert(m.size() == 0);82    }83    {84        std::cmatch m;85        const char s[] = "abbc";86        assert(std::regex_match(s, m, std::regex("ab*c")));87        assert(m.size() == 1);88        assert(!m.prefix().matched);89        assert(m.prefix().first == s);90        assert(m.prefix().second == m[0].first);91        assert(!m.suffix().matched);92        assert(m.suffix().first == m[0].second);93        assert(m.suffix().second == s+4);94        assert(m.length(0) == 4);95        assert(m.position(0) == 0);96        assert(m.str(0) == s);97    }98    {99        std::cmatch m;100        const char s[] = "ababc";101        assert(std::regex_match(s, m, std::regex("(ab)*c")));102        assert(m.size() == 2);103        assert(!m.prefix().matched);104        assert(m.prefix().first == s);105        assert(m.prefix().second == m[0].first);106        assert(!m.suffix().matched);107        assert(m.suffix().first == m[0].second);108        assert(m.suffix().second == s+5);109        assert(m.length(0) == 5);110        assert(m.position(0) == 0);111        assert(m.str(0) == s);112        assert(m.length(1) == 2);113        assert(m.position(1) == 2);114        assert(m.str(1) == "ab");115    }116    {117        std::cmatch m;118        const char s[] = "abcdefghijk";119        assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi")));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")));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")));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")));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$")));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$")));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$")));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")));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")));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")));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("(.*).*")));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*)*")));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")));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")));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")));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")));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")));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")));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")));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")));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")));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")));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")));363        assert(m.size() == 0);364    }365    {366        std::cmatch m;367        // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273368        const char s[] = "tournament";369        assert(std::regex_match(s, m, std::regex("tour|to|tournament")));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        // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273384        const char s[] = "tournamenttotour";385        assert(386            std::regex_match(s, m, std::regex("(tour|to|tournament)+",387                                              std::regex_constants::nosubs)));388        assert(m.size() == 1);389        assert(!m.prefix().matched);390        assert(m.prefix().first == s);391        assert(m.prefix().second == m[0].first);392        assert(!m.suffix().matched);393        assert(m.suffix().first == m[0].second);394        assert(m.suffix().second == m[0].second);395        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));396        assert(m.position(0) == 0);397        assert(m.str(0) == s);398    }399    {400        std::cmatch m;401        const char s[] = "ttotour";402        assert(std::regex_match(s, m, std::regex("(tour|to|t)+")));403        assert(m.size() == 2);404        assert(!m.prefix().matched);405        assert(m.prefix().first == s);406        assert(m.prefix().second == m[0].first);407        assert(!m.suffix().matched);408        assert(m.suffix().first == m[0].second);409        assert(m.suffix().second == m[0].second);410        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));411        assert(m.position(0) == 0);412        assert(m.str(0) == s);413        assert(m.length(1) == 4);414        assert(m.position(1) == 3);415        assert(m.str(1) == "tour");416    }417    {418        std::cmatch m;419        const char s[] = "-ab,ab-";420        assert(!std::regex_match(s, m, std::regex("-(.*),\1-")));421        assert(m.size() == 0);422    }423    {424        std::cmatch m;425        const char s[] = "-ab,ab-";426        assert(std::regex_match(s, m, std::regex("-.*,.*-")));427        assert(m.size() == 1);428        assert(!m.prefix().matched);429        assert(m.prefix().first == s);430        assert(m.prefix().second == m[0].first);431        assert(!m.suffix().matched);432        assert(m.suffix().first == m[0].second);433        assert(m.suffix().second == m[0].second);434        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));435        assert(m.position(0) == 0);436        assert(m.str(0) == s);437    }438    {439        std::cmatch m;440        const char s[] = "a";441        assert(std::regex_match(s, m, std::regex("^[a]$")));442        assert(m.size() == 1);443        assert(!m.prefix().matched);444        assert(m.prefix().first == s);445        assert(m.prefix().second == m[0].first);446        assert(!m.suffix().matched);447        assert(m.suffix().first == m[0].second);448        assert(m.suffix().second == m[0].second);449        assert(m.length(0) == 1);450        assert(m.position(0) == 0);451        assert(m.str(0) == "a");452    }453    {454        std::cmatch m;455        const char s[] = "a";456        assert(std::regex_match(s, m, std::regex("^[ab]$")));457        assert(m.size() == 1);458        assert(!m.prefix().matched);459        assert(m.prefix().first == s);460        assert(m.prefix().second == m[0].first);461        assert(!m.suffix().matched);462        assert(m.suffix().first == m[0].second);463        assert(m.suffix().second == m[0].second);464        assert(m.length(0) == 1);465        assert(m.position(0) == 0);466        assert(m.str(0) == "a");467    }468    {469        std::cmatch m;470        const char s[] = "c";471        assert(std::regex_match(s, m, std::regex("^[a-f]$")));472        assert(m.size() == 1);473        assert(!m.prefix().matched);474        assert(m.prefix().first == s);475        assert(m.prefix().second == m[0].first);476        assert(!m.suffix().matched);477        assert(m.suffix().first == m[0].second);478        assert(m.suffix().second == m[0].second);479        assert(m.length(0) == 1);480        assert(m.position(0) == 0);481        assert(m.str(0) == s);482    }483    {484        std::cmatch m;485        const char s[] = "g";486        assert(!std::regex_match(s, m, std::regex("^[a-f]$")));487        assert(m.size() == 0);488    }489    {490        std::cmatch m;491        const char s[] = "Iraqi";492        assert(!std::regex_match(s, m, std::regex("q[^u]")));493        assert(m.size() == 0);494    }495    {496        std::cmatch m;497        const char s[] = "Iraq";498        assert(!std::regex_match(s, m, std::regex("q[^u]")));499        assert(m.size() == 0);500    }501    {502        std::cmatch m;503        const char s[] = "AmB";504        assert(std::regex_match(s, m, std::regex("A[[:lower:]]B")));505        assert(m.size() == 1);506        assert(!m.prefix().matched);507        assert(m.prefix().first == s);508        assert(m.prefix().second == m[0].first);509        assert(!m.suffix().matched);510        assert(m.suffix().first == m[0].second);511        assert(m.suffix().second == m[0].second);512        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));513        assert(m.position(0) == 0);514        assert(m.str(0) == s);515    }516    {517        std::cmatch m;518        const char s[] = "AMB";519        assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B")));520        assert(m.size() == 0);521    }522    {523        std::cmatch m;524        const char s[] = "AMB";525        assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B")));526        assert(m.size() == 1);527        assert(!m.prefix().matched);528        assert(m.prefix().first == s);529        assert(m.prefix().second == m[0].first);530        assert(!m.suffix().matched);531        assert(m.suffix().first == m[0].second);532        assert(m.suffix().second == m[0].second);533        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));534        assert(m.position(0) == 0);535        assert(m.str(0) == s);536    }537    {538        std::cmatch m;539        const char s[] = "AmB";540        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B")));541        assert(m.size() == 0);542    }543    {544        std::cmatch m;545        const char s[] = "A5B";546        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));547        assert(m.size() == 0);548    }549    {550        std::cmatch m;551        const char s[] = "A?B";552        assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));553        assert(m.size() == 1);554        assert(!m.prefix().matched);555        assert(m.prefix().first == s);556        assert(m.prefix().second == m[0].first);557        assert(!m.suffix().matched);558        assert(m.suffix().first == m[0].second);559        assert(m.suffix().second == m[0].second);560        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));561        assert(m.position(0) == 0);562        assert(m.str(0) == s);563    }564    {565        std::cmatch m;566        const char s[] = "m";567        assert(std::regex_match(s, m, std::regex("[a[=m=]z]")));568        assert(m.size() == 1);569        assert(!m.prefix().matched);570        assert(m.prefix().first == s);571        assert(m.prefix().second == m[0].first);572        assert(!m.suffix().matched);573        assert(m.suffix().first == m[0].second);574        assert(m.suffix().second == m[0].second);575        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));576        assert(m.position(0) == 0);577        assert(m.str(0) == s);578    }579    {580        std::cmatch m;581        const char s[] = "m";582        assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));583        assert(m.size() == 0);584    }585    {586        std::cmatch m;587        const char s[] = "-";588        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));589        assert(m.size() == 1);590        assert(!m.prefix().matched);591        assert(m.prefix().first == s);592        assert(m.prefix().second == m[0].first);593        assert(!m.suffix().matched);594        assert(m.suffix().first == m[0].second);595        assert(m.suffix().second == m[0].second);596        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));597        assert(m.position(0) == 0);598        assert(m.str(0) == s);599    }600    {601        std::cmatch m;602        const char s[] = "z";603        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));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<std::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        assert(m.size() == 0);620    }621    {622        std::cmatch m;623        const char s[] = "foobar";624        assert(std::regex_match(s, m, std::regex("[^\\0]*")));625        assert(m.size() == 1);626    }627    {628        std::cmatch m;629        const char s[] = "foo\0bar";630        assert(std::regex_match(s, s+7, m, std::regex("[abfor\\0]*")));631        assert(m.size() == 1);632    }633    {634        std::cmatch m;635        const char s[] = "01a45cef9";636        assert(!std::regex_match(s, m, std::regex("[ace1-9]*")));637        assert(m.size() == 0);638    }639    {640        std::cmatch m;641        const char s[] = "01a45cef9";642        assert(!std::regex_match(s, m, std::regex("[ace1-9]+")));643        assert(m.size() == 0);644    }645    {646        const char r[] = "^[-+]?[0-9]+[CF]$";647        std::ptrdiff_t sr = std::char_traits<char>::length(r);648        typedef forward_iterator<const char*> FI;649        typedef bidirectional_iterator<const char*> BI;650        std::regex regex(FI(r), FI(r+sr));651        std::match_results<BI> m;652        const char s[] = "-40C";653        std::ptrdiff_t ss = std::char_traits<char>::length(s);654        assert(std::regex_match(BI(s), BI(s+ss), m, regex));655        assert(m.size() == 1);656        assert(!m.prefix().matched);657        assert(m.prefix().first == BI(s));658        assert(m.prefix().second == m[0].first);659        assert(!m.suffix().matched);660        assert(m.suffix().first == m[0].second);661        assert(m.suffix().second == m[0].second);662        assert(m.length(0) == 4);663        assert(m.position(0) == 0);664        assert(m.str(0) == s);665    }666    {667        std::cmatch m;668        const char s[] = "Jeff Jeffs ";669        assert(!std::regex_match(s, m, std::regex("Jeff(?=s\\b)")));670        assert(m.size() == 0);671    }672    {673        std::cmatch m;674        const char s[] = "Jeffs Jeff";675        assert(!std::regex_match(s, m, std::regex("Jeff(?!s\\b)")));676        assert(m.size() == 0);677    }678    {679        std::cmatch m;680        const char s[] = "5%k";681        assert(std::regex_match(s, m, std::regex("\\d[\\W]k")));682        assert(m.size() == 1);683        assert(!m.prefix().matched);684        assert(m.prefix().first == s);685        assert(m.prefix().second == m[0].first);686        assert(!m.suffix().matched);687        assert(m.suffix().first == m[0].second);688        assert(m.suffix().second == s + std::char_traits<char>::length(s));689        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));690        assert(m.position(0) == 0);691        assert(m.str(0) == s);692    }693    {694      std::cmatch m;695      const char s[] = "$_se";696      assert(std::regex_match(s, m, std::regex("\\$\\_se")));697      assert(m.size() == 1);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 + std::char_traits<char>::length(s));704      assert(m.length(0) >= 0 && static_cast<size_t>(m.length(0)) == std::char_traits<char>::length(s));705      assert(m.position(0) == 0);706      assert(m.str(0) == s);707    }708 709#ifndef TEST_HAS_NO_WIDE_CHARACTERS710    {711        std::wcmatch m;712        const wchar_t s[] = L"a";713        assert(std::regex_match(s, m, std::wregex(L"a")));714        assert(m.size() == 1);715        assert(!m.empty());716        assert(!m.prefix().matched);717        assert(m.prefix().first == s);718        assert(m.prefix().second == m[0].first);719        assert(!m.suffix().matched);720        assert(m.suffix().first == m[0].second);721        assert(m.suffix().second == s+1);722        assert(m.length(0) == 1);723        assert(m.position(0) == 0);724        assert(m.str(0) == L"a");725    }726    {727        std::wcmatch m;728        const wchar_t s[] = L"ab";729        assert(std::regex_match(s, m, std::wregex(L"ab")));730        assert(m.size() == 1);731        assert(!m.prefix().matched);732        assert(m.prefix().first == s);733        assert(m.prefix().second == m[0].first);734        assert(!m.suffix().matched);735        assert(m.suffix().first == m[0].second);736        assert(m.suffix().second == s+2);737        assert(m.length(0) == 2);738        assert(m.position(0) == 0);739        assert(m.str(0) == L"ab");740    }741    {742        std::wcmatch m;743        const wchar_t s[] = L"ab";744        assert(!std::regex_match(s, m, std::wregex(L"ba")));745        assert(m.size() == 0);746        assert(m.empty());747    }748    {749        std::wcmatch m;750        const wchar_t s[] = L"aab";751        assert(!std::regex_match(s, m, std::wregex(L"ab")));752        assert(m.size() == 0);753    }754    {755        std::wcmatch m;756        const wchar_t s[] = L"aab";757        assert(!std::regex_match(s, m, std::wregex(L"ab"),758                                            std::regex_constants::match_continuous));759        assert(m.size() == 0);760    }761    {762        std::wcmatch m;763        const wchar_t s[] = L"abcd";764        assert(!std::regex_match(s, m, std::wregex(L"bc")));765        assert(m.size() == 0);766    }767    {768        std::wcmatch m;769        const wchar_t s[] = L"abbc";770        assert(std::regex_match(s, m, std::wregex(L"ab*c")));771        assert(m.size() == 1);772        assert(!m.prefix().matched);773        assert(m.prefix().first == s);774        assert(m.prefix().second == m[0].first);775        assert(!m.suffix().matched);776        assert(m.suffix().first == m[0].second);777        assert(m.suffix().second == s+4);778        assert(m.length(0) == 4);779        assert(m.position(0) == 0);780        assert(m.str(0) == s);781    }782    {783        std::wcmatch m;784        const wchar_t s[] = L"ababc";785        assert(std::regex_match(s, m, std::wregex(L"(ab)*c")));786        assert(m.size() == 2);787        assert(!m.prefix().matched);788        assert(m.prefix().first == s);789        assert(m.prefix().second == m[0].first);790        assert(!m.suffix().matched);791        assert(m.suffix().first == m[0].second);792        assert(m.suffix().second == s+5);793        assert(m.length(0) == 5);794        assert(m.position(0) == 0);795        assert(m.str(0) == s);796        assert(m.length(1) == 2);797        assert(m.position(1) == 2);798        assert(m.str(1) == L"ab");799    }800    {801        std::wcmatch m;802        const wchar_t s[] = L"abcdefghijk";803        assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi")));804        assert(m.size() == 0);805    }806    {807        std::wcmatch m;808        const wchar_t s[] = L"abc";809        assert(std::regex_match(s, m, std::wregex(L"^abc")));810        assert(m.size() == 1);811        assert(!m.prefix().matched);812        assert(m.prefix().first == s);813        assert(m.prefix().second == m[0].first);814        assert(!m.suffix().matched);815        assert(m.suffix().first == m[0].second);816        assert(m.suffix().second == s+3);817        assert(m.length(0) == 3);818        assert(m.position(0) == 0);819        assert(m.str(0) == s);820    }821    {822        std::wcmatch m;823        const wchar_t s[] = L"abcd";824        assert(!std::regex_match(s, m, std::wregex(L"^abc")));825        assert(m.size() == 0);826    }827    {828        std::wcmatch m;829        const wchar_t s[] = L"aabc";830        assert(!std::regex_match(s, m, std::wregex(L"^abc")));831        assert(m.size() == 0);832    }833    {834        std::wcmatch m;835        const wchar_t s[] = L"abc";836        assert(std::regex_match(s, m, std::wregex(L"abc$")));837        assert(m.size() == 1);838        assert(!m.prefix().matched);839        assert(m.prefix().first == s);840        assert(m.prefix().second == m[0].first);841        assert(!m.suffix().matched);842        assert(m.suffix().first == m[0].second);843        assert(m.suffix().second == s+3);844        assert(m.length(0) == 3);845        assert(m.position(0) == 0);846        assert(m.str(0) == s);847    }848    {849        std::wcmatch m;850        const wchar_t s[] = L"efabc";851        assert(!std::regex_match(s, m, std::wregex(L"abc$")));852        assert(m.size() == 0);853    }854    {855        std::wcmatch m;856        const wchar_t s[] = L"efabcg";857        assert(!std::regex_match(s, m, std::wregex(L"abc$")));858        assert(m.size() == 0);859    }860    {861        std::wcmatch m;862        const wchar_t s[] = L"abc";863        assert(std::regex_match(s, m, std::wregex(L"a.c")));864        assert(m.size() == 1);865        assert(!m.prefix().matched);866        assert(m.prefix().first == s);867        assert(m.prefix().second == m[0].first);868        assert(!m.suffix().matched);869        assert(m.suffix().first == m[0].second);870        assert(m.suffix().second == s+3);871        assert(m.length(0) == 3);872        assert(m.position(0) == 0);873        assert(m.str(0) == s);874    }875    {876        std::wcmatch m;877        const wchar_t s[] = L"acc";878        assert(std::regex_match(s, m, std::wregex(L"a.c")));879        assert(m.size() == 1);880        assert(!m.prefix().matched);881        assert(m.prefix().first == s);882        assert(m.prefix().second == m[0].first);883        assert(!m.suffix().matched);884        assert(m.suffix().first == m[0].second);885        assert(m.suffix().second == s+3);886        assert(m.length(0) == 3);887        assert(m.position(0) == 0);888        assert(m.str(0) == s);889    }890    {891        std::wcmatch m;892        const wchar_t s[] = L"acc";893        assert(std::regex_match(s, m, std::wregex(L"a.c")));894        assert(m.size() == 1);895        assert(!m.prefix().matched);896        assert(m.prefix().first == s);897        assert(m.prefix().second == m[0].first);898        assert(!m.suffix().matched);899        assert(m.suffix().first == m[0].second);900        assert(m.suffix().second == s+3);901        assert(m.length(0) == 3);902        assert(m.position(0) == 0);903        assert(m.str(0) == s);904    }905    {906        std::wcmatch m;907        const wchar_t s[] = L"abcdef";908        assert(std::regex_match(s, m, std::wregex(L"(.*).*")));909        assert(m.size() == 2);910        assert(!m.prefix().matched);911        assert(m.prefix().first == s);912        assert(m.prefix().second == m[0].first);913        assert(!m.suffix().matched);914        assert(m.suffix().first == m[0].second);915        assert(m.suffix().second == s+6);916        assert(m.length(0) == 6);917        assert(m.position(0) == 0);918        assert(m.str(0) == s);919        assert(m.length(1) == 6);920        assert(m.position(1) == 0);921        assert(m.str(1) == s);922    }923    {924        std::wcmatch m;925        const wchar_t s[] = L"bc";926        assert(!std::regex_match(s, m, std::wregex(L"(a*)*")));927        assert(m.size() == 0);928    }929    {930        std::wcmatch m;931        const wchar_t s[] = L"abbc";932        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));933        assert(m.size() == 0);934    }935    {936        std::wcmatch m;937        const wchar_t s[] = L"abbbc";938        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));939        assert(m.size() == 1);940        assert(!m.prefix().matched);941        assert(m.prefix().first == s);942        assert(m.prefix().second == m[0].first);943        assert(!m.suffix().matched);944        assert(m.suffix().first == m[0].second);945        assert(m.suffix().second == m[0].second);946        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));947        assert(m.position(0) == 0);948        assert(m.str(0) == s);949    }950    {951        std::wcmatch m;952        const wchar_t s[] = L"abbbbc";953        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));954        assert(m.size() == 1);955        assert(!m.prefix().matched);956        assert(m.prefix().first == s);957        assert(m.prefix().second == m[0].first);958        assert(!m.suffix().matched);959        assert(m.suffix().first == m[0].second);960        assert(m.suffix().second == m[0].second);961        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));962        assert(m.position(0) == 0);963        assert(m.str(0) == s);964    }965    {966        std::wcmatch m;967        const wchar_t s[] = L"abbbbbc";968        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));969        assert(m.size() == 1);970        assert(!m.prefix().matched);971        assert(m.prefix().first == s);972        assert(m.prefix().second == m[0].first);973        assert(!m.suffix().matched);974        assert(m.suffix().first == m[0].second);975        assert(m.suffix().second == m[0].second);976        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));977        assert(m.position(0) == 0);978        assert(m.str(0) == s);979    }980    {981        std::wcmatch m;982        const wchar_t s[] = L"adefc";983        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));984        assert(m.size() == 0);985    }986    {987        std::wcmatch m;988        const wchar_t s[] = L"abbbbbbc";989        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));990        assert(m.size() == 0);991    }992    {993        std::wcmatch m;994        const wchar_t s[] = L"adec";995        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));996        assert(m.size() == 0);997    }998    {999        std::wcmatch m;1000        const wchar_t s[] = L"adefc";1001        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));1002        assert(m.size() == 1);1003        assert(!m.prefix().matched);1004        assert(m.prefix().first == s);1005        assert(m.prefix().second == m[0].first);1006        assert(!m.suffix().matched);1007        assert(m.suffix().first == m[0].second);1008        assert(m.suffix().second == m[0].second);1009        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1010        assert(m.position(0) == 0);1011        assert(m.str(0) == s);1012    }1013    {1014        std::wcmatch m;1015        const wchar_t s[] = L"adefgc";1016        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));1017        assert(m.size() == 1);1018        assert(!m.prefix().matched);1019        assert(m.prefix().first == s);1020        assert(m.prefix().second == m[0].first);1021        assert(!m.suffix().matched);1022        assert(m.suffix().first == m[0].second);1023        assert(m.suffix().second == m[0].second);1024        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1025        assert(m.position(0) == 0);1026        assert(m.str(0) == s);1027    }1028    {1029        std::wcmatch m;1030        const wchar_t s[] = L"adefghc";1031        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));1032        assert(m.size() == 1);1033        assert(!m.prefix().matched);1034        assert(m.prefix().first == s);1035        assert(m.prefix().second == m[0].first);1036        assert(!m.suffix().matched);1037        assert(m.suffix().first == m[0].second);1038        assert(m.suffix().second == m[0].second);1039        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1040        assert(m.position(0) == 0);1041        assert(m.str(0) == s);1042    }1043    {1044        std::wcmatch m;1045        const wchar_t s[] = L"adefghic";1046        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));1047        assert(m.size() == 0);1048    }1049    {1050        std::wcmatch m;1051        // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#22731052        const wchar_t s[] = L"tournament";1053        assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament")));1054        assert(m.size() == 1);1055        assert(!m.prefix().matched);1056        assert(m.prefix().first == s);1057        assert(m.prefix().second == m[0].first);1058        assert(!m.suffix().matched);1059        assert(m.suffix().first == m[0].second);1060        assert(m.suffix().second == m[0].second);1061        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1062        assert(m.position(0) == 0);1063        assert(m.str(0) == s);1064    }1065    {1066        std::wcmatch m;1067        // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#22731068        const wchar_t s[] = L"tournamenttotour";1069        assert(1070            std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",1071                                               std::regex_constants::nosubs)));1072        assert(m.size() == 1);1073        assert(!m.prefix().matched);1074        assert(m.prefix().first == s);1075        assert(m.prefix().second == m[0].first);1076        assert(!m.suffix().matched);1077        assert(m.suffix().first == m[0].second);1078        assert(m.suffix().second == m[0].second);1079        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1080        assert(m.position(0) == 0);1081        assert(m.str(0) == s);1082    }1083    {1084        std::wcmatch m;1085        const wchar_t s[] = L"ttotour";1086        assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+")));1087        assert(m.size() == 2);1088        assert(!m.prefix().matched);1089        assert(m.prefix().first == s);1090        assert(m.prefix().second == m[0].first);1091        assert(!m.suffix().matched);1092        assert(m.suffix().first == m[0].second);1093        assert(m.suffix().second == m[0].second);1094        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1095        assert(m.position(0) == 0);1096        assert(m.str(0) == s);1097        assert(m.length(1) == 4);1098        assert(m.position(1) == 3);1099        assert(m.str(1) == L"tour");1100    }1101    {1102        std::wcmatch m;1103        const wchar_t s[] = L"-ab,ab-";1104        assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-")));1105        assert(m.size() == 0);1106    }1107    {1108        std::wcmatch m;1109        const wchar_t s[] = L"-ab,ab-";1110        assert(std::regex_match(s, m, std::wregex(L"-.*,.*-")));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        assert(m.size() == 1);1127        assert(!m.prefix().matched);1128        assert(m.prefix().first == s);1129        assert(m.prefix().second == m[0].first);1130        assert(!m.suffix().matched);1131        assert(m.suffix().first == m[0].second);1132        assert(m.suffix().second == m[0].second);1133        assert(m.length(0) == 1);1134        assert(m.position(0) == 0);1135        assert(m.str(0) == L"a");1136    }1137    {1138        std::wcmatch m;1139        const wchar_t s[] = L"a";1140        assert(std::regex_match(s, m, std::wregex(L"^[ab]$")));1141        assert(m.size() == 1);1142        assert(!m.prefix().matched);1143        assert(m.prefix().first == s);1144        assert(m.prefix().second == m[0].first);1145        assert(!m.suffix().matched);1146        assert(m.suffix().first == m[0].second);1147        assert(m.suffix().second == m[0].second);1148        assert(m.length(0) == 1);1149        assert(m.position(0) == 0);1150        assert(m.str(0) == L"a");1151    }1152    {1153        std::wcmatch m;1154        const wchar_t s[] = L"c";1155        assert(std::regex_match(s, m, std::wregex(L"^[a-f]$")));1156        assert(m.size() == 1);1157        assert(!m.prefix().matched);1158        assert(m.prefix().first == s);1159        assert(m.prefix().second == m[0].first);1160        assert(!m.suffix().matched);1161        assert(m.suffix().first == m[0].second);1162        assert(m.suffix().second == m[0].second);1163        assert(m.length(0) == 1);1164        assert(m.position(0) == 0);1165        assert(m.str(0) == s);1166    }1167    {1168        std::wcmatch m;1169        const wchar_t s[] = L"g";1170        assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$")));1171        assert(m.size() == 0);1172    }1173    {1174        std::wcmatch m;1175        const wchar_t s[] = L"Iraqi";1176        assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));1177        assert(m.size() == 0);1178    }1179    {1180        std::wcmatch m;1181        const wchar_t s[] = L"Iraq";1182        assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));1183        assert(m.size() == 0);1184    }1185    {1186        std::wcmatch m;1187        const wchar_t s[] = L"AmB";1188        assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));1189        assert(m.size() == 1);1190        assert(!m.prefix().matched);1191        assert(m.prefix().first == s);1192        assert(m.prefix().second == m[0].first);1193        assert(!m.suffix().matched);1194        assert(m.suffix().first == m[0].second);1195        assert(m.suffix().second == m[0].second);1196        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1197        assert(m.position(0) == 0);1198        assert(m.str(0) == s);1199    }1200    {1201        std::wcmatch m;1202        const wchar_t s[] = L"AMB";1203        assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));1204        assert(m.size() == 0);1205    }1206    {1207        std::wcmatch m;1208        const wchar_t s[] = L"AMB";1209        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));1210        assert(m.size() == 1);1211        assert(!m.prefix().matched);1212        assert(m.prefix().first == s);1213        assert(m.prefix().second == m[0].first);1214        assert(!m.suffix().matched);1215        assert(m.suffix().first == m[0].second);1216        assert(m.suffix().second == m[0].second);1217        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1218        assert(m.position(0) == 0);1219        assert(m.str(0) == s);1220    }1221    {1222        std::wcmatch m;1223        const wchar_t s[] = L"AmB";1224        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));1225        assert(m.size() == 0);1226    }1227    {1228        std::wcmatch m;1229        const wchar_t s[] = L"A5B";1230        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));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        assert(m.size() == 1);1238        assert(!m.prefix().matched);1239        assert(m.prefix().first == s);1240        assert(m.prefix().second == m[0].first);1241        assert(!m.suffix().matched);1242        assert(m.suffix().first == m[0].second);1243        assert(m.suffix().second == m[0].second);1244        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1245        assert(m.position(0) == 0);1246        assert(m.str(0) == s);1247    }1248    {1249        std::wcmatch m;1250        const wchar_t s[] = L"m";1251        assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]")));1252        assert(m.size() == 1);1253        assert(!m.prefix().matched);1254        assert(m.prefix().first == s);1255        assert(m.prefix().second == m[0].first);1256        assert(!m.suffix().matched);1257        assert(m.suffix().first == m[0].second);1258        assert(m.suffix().second == m[0].second);1259        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1260        assert(m.position(0) == 0);1261        assert(m.str(0) == s);1262    }1263    {1264        std::wcmatch m;1265        const wchar_t s[] = L"m";1266        assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));1267        assert(m.size() == 0);1268    }1269    {1270        std::wcmatch m;1271        const wchar_t s[] = L"-";1272        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));1273        assert(m.size() == 1);1274        assert(!m.prefix().matched);1275        assert(m.prefix().first == s);1276        assert(m.prefix().second == m[0].first);1277        assert(!m.suffix().matched);1278        assert(m.suffix().first == m[0].second);1279        assert(m.suffix().second == m[0].second);1280        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1281        assert(m.position(0) == 0);1282        assert(m.str(0) == s);1283    }1284    {1285        std::wcmatch m;1286        const wchar_t s[] = L"z";1287        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));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"m";1302        assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));1303        assert(m.size() == 0);1304    }1305    {1306        std::wcmatch m;1307        const wchar_t s[] = L"01a45cef9";1308        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*")));1309        assert(m.size() == 0);1310    }1311    {1312        std::wcmatch m;1313        const wchar_t s[] = L"01a45cef9";1314        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+")));1315        assert(m.size() == 0);1316    }1317    {1318        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";1319        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);1320        typedef forward_iterator<const wchar_t*> FI;1321        typedef bidirectional_iterator<const wchar_t*> BI;1322        std::wregex regex(FI(r), FI(r+sr));1323        std::match_results<BI> m;1324        const wchar_t s[] = L"-40C";1325        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);1326        assert(std::regex_match(BI(s), BI(s+ss), m, regex));1327        assert(m.size() == 1);1328        assert(!m.prefix().matched);1329        assert(m.prefix().first == BI(s));1330        assert(m.prefix().second == m[0].first);1331        assert(!m.suffix().matched);1332        assert(m.suffix().first == m[0].second);1333        assert(m.suffix().second == m[0].second);1334        assert(m.length(0) == 4);1335        assert(m.position(0) == 0);1336        assert(m.str(0) == s);1337    }1338    {1339        std::wcmatch m;1340        const wchar_t s[] = L"Jeff Jeffs ";1341        assert(!std::regex_match(s, m, std::wregex(L"Jeff(?=s\\b)")));1342        assert(m.size() == 0);1343    }1344    {1345        std::wcmatch m;1346        const wchar_t s[] = L"Jeffs Jeff";1347        assert(!std::regex_match(s, m, std::wregex(L"Jeff(?!s\\b)")));1348        assert(m.size() == 0);1349    }1350    {1351        std::wcmatch m;1352        const wchar_t s[] = L"5%k";1353        assert(std::regex_match(s, m, std::wregex(L"\\d[\\W]k")));1354        assert(m.size() == 1);1355        assert(!m.prefix().matched);1356        assert(m.prefix().first == s);1357        assert(m.prefix().second == m[0].first);1358        assert(!m.suffix().matched);1359        assert(m.suffix().first == m[0].second);1360        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));1361        assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1362        assert(m.position(0) == 0);1363        assert(m.str(0) == s);1364    }1365    {1366      std::wcmatch m;1367      const wchar_t s[] = L"$_se";1368      assert(std::regex_match(s, m, std::wregex(L"\\$\\_se")));1369      assert(m.size() == 1);1370      assert(!m.prefix().matched);1371      assert(m.prefix().first == s);1372      assert(m.prefix().second == m[0].first);1373      assert(!m.suffix().matched);1374      assert(m.suffix().first == m[0].second);1375      assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));1376      assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));1377      assert(m.position(0) == 0);1378      assert(m.str(0) == s);1379    }1380#endif // TEST_HAS_NO_WIDE_CHARACTERS1381 1382  return 0;1383}1384