blob: 0b4c6948140ec8194abcdea6dc27eff8c04a2add [file] [log] [blame]
Howard Hinnantc1ecd972013-06-28 20:31:05 +00001//===----------------------------------------------------------------------===//
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{
Eric Fiseliere4e883e2014-10-27 19:29:32 +000028 std::string re("\\{a\\}");
29 std::string target("{a}");
30 std::regex regex(re);
Howard Hinnantc1ecd972013-06-28 20:31:05 +000031 std::smatch smatch;
32 assert((std::regex_match(target, smatch, regex)));
33}
34
35void
36test2()
37{
Eric Fiseliere4e883e2014-10-27 19:29:32 +000038 std::string re("\\{a\\}");
39 std::string target("{a}");
40 std::regex regex(re, std::regex::extended);
Howard Hinnantc1ecd972013-06-28 20:31:05 +000041 std::smatch smatch;
42 assert((std::regex_match(target, smatch, regex)));
43}
44
45void
46test3()
47{
Eric Fiseliere4e883e2014-10-27 19:29:32 +000048 std::string re("\\{a\\}");
49 std::string target("{a}");
50 std::regex regex(re, std::regex::awk);
Howard Hinnantc1ecd972013-06-28 20:31:05 +000051 std::smatch smatch;
52 assert((std::regex_match(target, smatch, regex)));
53}
54
55void
56test4()
57{
Eric Fiseliere4e883e2014-10-27 19:29:32 +000058 std::string re("\\{a\\}");
59 std::string target("{a}");
60 std::regex regex(re, std::regex::egrep);
Howard Hinnantc1ecd972013-06-28 20:31:05 +000061 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}