brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 6ed2645 Raw
41 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <regex>10// UNSUPPORTED: no-exceptions11// UNSUPPORTED: c++0312 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 19int 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