| 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 | // UNSUPPORTED: no-exceptions |
| 11 | // UNSUPPORTED: c++03 |
| 12 | |
| 13 | // the "n" in `a{n}` should be within the numeric limits. |
| 14 | |
| 15 | #include <regex> |
| 16 | #include <cassert> |
| 17 | #include "test_macros.h" |
| 18 | |
| 19 | int main(int, char**) { |
| 20 | for (std::regex_constants::syntax_option_type op : |
| 21 | {std::regex::basic, std::regex::grep}) { |
| 22 | try { |
| 23 | TEST_IGNORE_NODISCARD std::regex("a\\{100000000000000000\\}" , op); |
| 24 | assert(false); |
| 25 | } catch (const std::regex_error &e) { |
| 26 | assert(e.code() == std::regex_constants::error_badbrace); |
| 27 | } |
| 28 | } |
| 29 | for (std::regex_constants::syntax_option_type op : |
| 30 | {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, |
| 31 | std::regex::awk}) { |
| 32 | try { |
| 33 | TEST_IGNORE_NODISCARD std::regex("a{100000000000000000}" , op); |
| 34 | assert(false); |
| 35 | } catch (const std::regex_error &e) { |
| 36 | assert(e.code() == std::regex_constants::error_badbrace); |
| 37 | } |
| 38 | } |
| 39 | return 0; |
| 40 | } |
| 41 | |