[OpenMP][Docs] Update OpenMP supported features table (#126292)
[llvm-project.git] / libcxx / test / std / re / re.regex / re.regex.construct / iter_iter_flg.pass.cpp
blob22423c09282075cb48d4f2e94ffa49144e014194
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 ForwardIterator>
14 // basic_regex(ForwardIterator first, ForwardIterator last,
15 // flag_type f = regex_constants::ECMAScript);
17 #include <regex>
18 #include <cassert>
20 #include "test_iterators.h"
21 #include "test_macros.h"
23 template <class Iter>
24 void
25 test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
27 std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
28 assert(r.flags() == f);
29 assert(r.mark_count() == mc);
32 int main(int, char**)
34 typedef forward_iterator<std::string::const_iterator> F;
35 std::string s1("\\(a\\)");
36 std::string s2("\\(a[bc]\\)");
37 std::string s3("\\(a\\([bc]\\)\\)");
38 std::string s4("(a([bc]))");
40 test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
41 test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
42 test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
43 test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
45 test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
46 test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
47 test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
48 test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
50 test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
51 test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
52 test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
53 test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
55 test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
56 test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
57 test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
58 test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
60 test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
61 test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
62 test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
63 test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
65 test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
66 test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
67 test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
68 test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
70 return 0;