[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / re / re.regex / re.regex.construct / bad_repeat.pass.cpp
blobb600ef70e176a0c956b04a56ae7580d2ec797814
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 // UNSUPPORTED: no-exceptions
10 // <regex>
12 // template <class charT, class traits = regex_traits<charT>> class basic_regex;
14 // template <class ST, class SA>
15 // basic_regex(const basic_string<charT, ST, SA>& s);
17 #include <regex>
18 #include <cassert>
19 #include "test_macros.h"
21 static bool error_badrepeat_thrown(const char *pat)
23 bool result = false;
24 try {
25 std::regex re(pat);
26 } catch (const std::regex_error &ex) {
27 result = (ex.code() == std::regex_constants::error_badrepeat);
29 return result;
32 int main(int, char**)
34 assert(error_badrepeat_thrown("?a"));
35 assert(error_badrepeat_thrown("*a"));
36 assert(error_badrepeat_thrown("+a"));
37 assert(error_badrepeat_thrown("{a"));
39 assert(error_badrepeat_thrown("?(a+)"));
40 assert(error_badrepeat_thrown("*(a+)"));
41 assert(error_badrepeat_thrown("+(a+)"));
42 assert(error_badrepeat_thrown("{(a+)"));
44 return 0;