brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · a680baf Raw
74 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <regex>10 11// template <class BidirectionalIterator, class Allocator, class charT, class traits>12//     bool13//     regex_match(BidirectionalIterator first, BidirectionalIterator last,14//                  match_results<BidirectionalIterator, Allocator>& m,15//                  const basic_regex<charT, traits>& e,16//                  regex_constants::match_flag_type flags = regex_constants::match_default);17 18// https://llvm.org/PR1613519 20#include <string>21#include <regex>22#include <cassert>23#include "test_macros.h"24 25void26test1()27{28    std::string re("\\{a\\}");29    std::string target("{a}");30    std::regex regex(re);31    std::smatch smatch;32    assert((std::regex_match(target, smatch, regex)));33}34 35void36test2()37{38    std::string re("\\{a\\}");39    std::string target("{a}");40    std::regex regex(re, std::regex::extended);41    std::smatch smatch;42    assert((std::regex_match(target, smatch, regex)));43}44 45void46test3()47{48    std::string re("\\{a\\}");49    std::string target("{a}");50    std::regex regex(re, std::regex::awk);51    std::smatch smatch;52    assert((std::regex_match(target, smatch, regex)));53}54 55void56test4()57{58    std::string re("\\{a\\}");59    std::string target("{a}");60    std::regex regex(re, std::regex::egrep);61    std::smatch smatch;62    assert((std::regex_match(target, smatch, regex)));63}64 65int main(int, char**)66{67    test1();68    test2();69    test3();70    test4();71 72  return 0;73}74