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 // https://bugs.llvm.org/show_bug.cgi?id=16135 20 21 #include <string> 22 #include <regex> 23 #include <cassert> 24 #include "test_macros.h" 25 26 void 27 test1() 28 { 29 std::string re("\\{a\\}"); 30 std::string target("{a}"); 31 std::regex regex(re); 32 std::smatch smatch; 33 assert((std::regex_match(target, smatch, regex))); 34 } 35 36 void 37 test2() 38 { 39 std::string re("\\{a\\}"); 40 std::string target("{a}"); 41 std::regex regex(re, std::regex::extended); 42 std::smatch smatch; 43 assert((std::regex_match(target, smatch, regex))); 44 } 45 46 void 47 test3() 48 { 49 std::string re("\\{a\\}"); 50 std::string target("{a}"); 51 std::regex regex(re, std::regex::awk); 52 std::smatch smatch; 53 assert((std::regex_match(target, smatch, regex))); 54 } 55 56 void 57 test4() 58 { 59 std::string re("\\{a\\}"); 60 std::string target("{a}"); 61 std::regex regex(re, std::regex::egrep); 62 std::smatch smatch; 63 assert((std::regex_match(target, smatch, regex))); 64 } 65 66 int 67 main() 68 { 69 test1(); 70 test2(); 71 test3(); 72 test4(); 73 } 74