brintos

brintos / llvm-project-archived public Read only

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