1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: no-exceptions
13 // the "n" and "m" in `a{n,m}` should be within the numeric limits.
14 // requirement "m >= n" should be checked.
18 #include "test_macros.h"
20 int main(int, char**) {
22 for (std::regex_constants::syntax_option_type op
:
23 {std::regex::basic
}) {
25 TEST_IGNORE_NODISCARD
std::regex("a\\{3,2\\}", op
);
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
,
36 TEST_IGNORE_NODISCARD
std::regex("a{3,2}", op
);
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
}) {
48 TEST_IGNORE_NODISCARD
std::regex("a\\{100000000000000000000,10000000000000000000\\}", op
);
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
,
59 TEST_IGNORE_NODISCARD
std::regex("a{100000000000000000000,10000000000000000000}", op
);
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
);