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