[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / re / re.regex / re.regex.construct / string_flg.pass.cpp
blobb6bd8c53c5ae2245bfedde57b443e0e516cd31e5
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 // <regex>
11 // template <class charT, class traits = regex_traits<charT>> class basic_regex;
13 // template <class ST, class SA>
14 // basic_regex(const basic_string<charT, ST, SA>& s,
15 // flag_type f = regex_constants::ECMAScript);
17 #include <regex>
18 #include <cassert>
19 #include "test_macros.h"
21 template <class String>
22 void
23 test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
25 std::basic_regex<typename String::value_type> r(p, f);
26 assert(r.flags() == f);
27 assert(r.mark_count() == mc);
30 int main(int, char**)
32 test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
33 test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
34 test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
35 test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
37 test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
38 test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
39 test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
40 test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
42 test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
43 test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
44 test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
45 test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
47 test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
48 test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
49 test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
50 test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
52 test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
53 test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
54 test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
55 test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
57 test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
58 test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
59 test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
60 test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
62 return 0;