blob: 9c5f834b9452a9a175a4d0ebf80eb88a748f5be9 [file] [log] [blame]
Howard Hinnant5cd66582010-08-13 18:11:23 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant412dbeb2010-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 Hinnant5cd66582010-08-13 18:11:23 +00007//
8//===----------------------------------------------------------------------===//
9
Asiri Rathnayakef520c142015-11-10 11:41:22 +000010// XFAIL: libcpp-no-exceptions
Howard Hinnant5cd66582010-08-13 18:11:23 +000011// <regex>
12
13// template <class charT, class traits = regex_traits<charT>> class basic_regex;
14
15// basic_regex& assign(const basic_regex& that);
16
17#include <regex>
18#include <cassert>
19
20int main()
21{
22 std::regex r1("(a([bc]))");
23 std::regex r2;
24 r2.assign(r1);
25 assert(r2.flags() == std::regex::ECMAScript);
26 assert(r2.mark_count() == 2);
Marshall Clow9db90692015-01-13 16:49:52 +000027 assert(std::regex_search("ab", r2));
28
29 bool caught = false;
30 try { r2.assign("(def", std::regex::extended); }
31 catch(std::regex_error &) { caught = true; }
32 assert(caught);
33 assert(r2.flags() == std::regex::ECMAScript);
34 assert(r2.mark_count() == 2);
35 assert(std::regex_search("ab", r2));
Howard Hinnant5cd66582010-08-13 18:11:23 +000036}