[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / re / re.grammar / excessive_brace_min_max.pass.cpp
blobd8f0502e67c9f80bba0ca7cace0057f325d1f5e7
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 //===----------------------------------------------------------------------===//
9 // <regex>
10 // UNSUPPORTED: no-exceptions
11 // UNSUPPORTED: c++03
13 // the "n" and "m" in `a{n,m}` should be within the numeric limits.
14 // requirement "m >= n" should be checked.
16 #include <regex>
17 #include <cassert>
18 #include "test_macros.h"
20 int main(int, char**) {
21 // test that `n <= m`
22 for (std::regex_constants::syntax_option_type op :
23 {std::regex::basic}) {
24 try {
25 TEST_IGNORE_NODISCARD std::regex("a\\{3,2\\}", op);
26 assert(false);
27 } catch (const std::regex_error &e) {
28 assert(e.code() == std::regex_constants::error_badbrace);
29 LIBCPP_ASSERT(e.code() == std::regex_constants::error_badbrace);
32 for (std::regex_constants::syntax_option_type op :
33 {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
34 std::regex::awk}) {
35 try {
36 TEST_IGNORE_NODISCARD std::regex("a{3,2}", op);
37 assert(false);
38 } catch (const std::regex_error &e) {
39 assert(e.code() == std::regex_constants::error_badbrace);
40 LIBCPP_ASSERT(e.code() == std::regex_constants::error_badbrace);
44 // test that both bounds are within the limit
45 for (std::regex_constants::syntax_option_type op :
46 {std::regex::basic}) {
47 try {
48 TEST_IGNORE_NODISCARD std::regex("a\\{100000000000000000000,10000000000000000000\\}", op);
49 assert(false);
50 } catch (const std::regex_error &e) {
51 assert(e.code() == std::regex_constants::error_badbrace);
52 LIBCPP_ASSERT(e.code() == std::regex_constants::error_badbrace);
55 for (std::regex_constants::syntax_option_type op :
56 {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
57 std::regex::awk}) {
58 try {
59 TEST_IGNORE_NODISCARD std::regex("a{100000000000000000000,10000000000000000000}", op);
60 assert(false);
61 } catch (const std::regex_error &e) {
62 assert(e.code() == std::regex_constants::error_badbrace);
63 LIBCPP_ASSERT(e.code() == std::regex_constants::error_badbrace);
66 return 0;