blob: 529a64a239a0eafe9363df68599838e227165691 [file] [log] [blame]
Howard Hinnant7026a172010-08-13 18:11:23 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant7026a172010-08-13 18:11:23 +00007//
8//===----------------------------------------------------------------------===//
9
10// <regex>
11
12// template <class charT, class traits = regex_traits<charT>> class basic_regex;
13
14// template <class InputIterator>
15// basic_regex&
16// assign(InputIterator first, InputIterator last,
17// flag_type f = regex_constants::ECMAScript);
18
19#include <regex>
20#include <cassert>
21
Marshall Clow83e2c4d2013-01-05 03:21:01 +000022#include "test_iterators.h"
Howard Hinnant7026a172010-08-13 18:11:23 +000023
24int main()
25{
26 typedef input_iterator<std::string::const_iterator> I;
27 typedef forward_iterator<std::string::const_iterator> F;
28 std::string s4("(a([bc]))");
29 std::regex r2;
30
31 r2.assign(I(s4.begin()), I(s4.end()));
32 assert(r2.flags() == std::regex::ECMAScript);
33 assert(r2.mark_count() == 2);
34
35 r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
36 assert(r2.flags() == std::regex::extended);
37 assert(r2.mark_count() == 2);
38
39 r2.assign(F(s4.begin()), F(s4.end()));
40 assert(r2.flags() == std::regex::ECMAScript);
41 assert(r2.mark_count() == 2);
42
43 r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
44 assert(r2.flags() == std::regex::extended);
45 assert(r2.mark_count() == 2);
46}