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// http://llvm.org/bugs/show_bug.cgi?id=16135 20 21#include <string> 22#include <regex> 23#include <cassert> 24 25void 26test1() 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 35void 36test2() 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 45void 46test3() 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 55void 56test4() 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 66main() 67{ 68 test1(); 69 test2(); 70 test3(); 71 test4(); 72} 73