Howard Hinnant | 5cd6658 | 2010-08-13 18:11:23 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Howard Hinnant | 5cd6658 | 2010-08-13 18:11:23 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <regex> |
| 10 | |
| 11 | // template <class charT, class traits = regex_traits<charT>> class basic_regex; |
| 12 | |
| 13 | // basic_regex& assign(const basic_regex& that); |
| 14 | |
| 15 | #include <regex> |
| 16 | #include <cassert> |
Marshall Clow | fd5ceb2 | 2016-04-26 16:24:44 +0000 | [diff] [blame] | 17 | #include "test_macros.h" |
Howard Hinnant | 5cd6658 | 2010-08-13 18:11:23 +0000 | [diff] [blame] | 18 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 19 | int main(int, char**) |
Howard Hinnant | 5cd6658 | 2010-08-13 18:11:23 +0000 | [diff] [blame] | 20 | { |
| 21 | std::regex r1("(a([bc]))"); |
| 22 | std::regex r2; |
| 23 | r2.assign(r1); |
| 24 | assert(r2.flags() == std::regex::ECMAScript); |
| 25 | assert(r2.mark_count() == 2); |
Marshall Clow | 9db9069 | 2015-01-13 16:49:52 +0000 | [diff] [blame] | 26 | assert(std::regex_search("ab", r2)); |
Eric Fiselier | d04c685 | 2016-06-01 21:35:39 +0000 | [diff] [blame] | 27 | |
Asiri Rathnayake | 08eb214 | 2016-10-06 11:15:41 +0000 | [diff] [blame] | 28 | #ifndef TEST_HAS_NO_EXCEPTIONS |
Marshall Clow | 9db9069 | 2015-01-13 16:49:52 +0000 | [diff] [blame] | 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)); |
Asiri Rathnayake | 08eb214 | 2016-10-06 11:15:41 +0000 | [diff] [blame] | 36 | #endif |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 37 | |
| 38 | return 0; |
Howard Hinnant | 5cd6658 | 2010-08-13 18:11:23 +0000 | [diff] [blame] | 39 | } |