[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / re / re.regex / re.regex.construct / il_flg.pass.cpp
blobd57c0f700b8a5080e5a5716c49d2e931c40f6551
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <regex>
13 // template <class charT, class traits = regex_traits<charT>> class basic_regex;
15 // basic_regex(initializer_list<charT> il,
16 // flag_type f = regex_constants::ECMAScript);
18 #include <regex>
19 #include <cassert>
20 #include "test_macros.h"
23 void
24 test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f, unsigned mc)
26 std::basic_regex<char> r(il, f);
27 assert(r.flags() == f);
28 assert(r.mark_count() == mc);
32 int main(int, char**)
34 std::string s1("\\(a\\)");
35 std::string s2("\\(a[bc]\\)");
36 std::string s3("\\(a\\([bc]\\)\\)");
37 std::string s4("(a([bc]))");
39 test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
40 test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
41 test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
42 test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::basic, 0);
44 test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::extended, 0);
45 test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::extended, 0);
46 test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::extended, 0);
47 test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::extended, 2);
49 test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::ECMAScript, 0);
50 test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::ECMAScript, 0);
51 test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::ECMAScript, 0);
52 test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::ECMAScript, 2);
54 test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::awk, 0);
55 test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::awk, 0);
56 test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::awk, 0);
57 test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::awk, 2);
59 test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::grep, 1);
60 test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::grep, 1);
61 test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::grep, 2);
62 test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::grep, 0);
64 test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::egrep, 0);
65 test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
66 test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
67 test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
69 return 0;