xref: /llvm-project/libcxx/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp (revision 60a6a0d17ad5afcac5c71dcf9a05f8c814951804)
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 charT, class traits = regex_traits<charT>> class basic_regex;
12 
13 // template <class InputIterator>
14 //    basic_regex&
15 //    assign(InputIterator first, InputIterator last,
16 //           flag_type f = regex_constants::ECMAScript);
17 
18 #include <cassert>
19 #include <regex>
20 #include <string>
21 
22 #include "test_macros.h"
23 #include "test_iterators.h"
24 
main(int,char **)25 int main(int, char**)
26 {
27     typedef cpp17_input_iterator<std::string::const_iterator> I;
28     typedef forward_iterator<std::string::const_iterator> F;
29     std::string s4("(a([bc]))");
30     std::regex r2;
31 
32     r2.assign(I(s4.begin()), I(s4.end()));
33     assert(r2.flags() == std::regex::ECMAScript);
34     assert(r2.mark_count() == 2);
35 
36     r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
37     assert(r2.flags() == std::regex::extended);
38     assert(r2.mark_count() == 2);
39 
40     r2.assign(F(s4.begin()), F(s4.end()));
41     assert(r2.flags() == std::regex::ECMAScript);
42     assert(r2.mark_count() == 2);
43 
44     r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
45     assert(r2.flags() == std::regex::extended);
46     assert(r2.mark_count() == 2);
47 
48   return 0;
49 }
50