• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <regex>
11 
12 // template <class charT, class traits = regex_traits<charT>> class basic_regex;
13 
14 // template <class ST, class SA>
15 //    basic_regex(const basic_string<charT, ST, SA>& s);
16 
17 #include <regex>
18 #include <cassert>
19 
error_badrepeat_thrown(const char * pat)20 static bool error_badrepeat_thrown(const char *pat)
21 {
22     bool result = false;
23     try {
24         std::regex re(pat);
25     } catch (const std::regex_error &ex) {
26         result = (ex.code() == std::regex_constants::error_badrepeat);
27     }
28     return result;
29 }
30 
main()31 int main()
32 {
33     assert(error_badrepeat_thrown("?a"));
34     assert(error_badrepeat_thrown("*a"));
35     assert(error_badrepeat_thrown("+a"));
36     assert(error_badrepeat_thrown("{a"));
37 
38     assert(error_badrepeat_thrown("?(a+)"));
39     assert(error_badrepeat_thrown("*(a+)"));
40     assert(error_badrepeat_thrown("+(a+)"));
41     assert(error_badrepeat_thrown("{(a+)"));
42 }
43