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-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <regex>
10
11 // template <class BidirectionalIterator, class Allocator, class charT, class traits>
12 // bool
13 // 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://bugs.llvm.org/show_bug.cgi?id=16135
19
20 #include <string>
21 #include <regex>
22 #include <cassert>
23 #include "test_macros.h"
24
25 void
test1()26 test1()
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
35 void
test2()36 test2()
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
45 void
test3()46 test3()
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
55 void
test4()56 test4()
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
main(int,char **)65 int main(int, char**)
66 {
67 test1();
68 test2();
69 test3();
70 test4();
71
72 return 0;
73 }
74