blob: bc70ec1302d672268b87e4c55f9f1a516b909105 [file] [log] [blame]
Marshall Clow568bd022015-07-23 18:27:51 +00001//===----------------------------------------------------------------------===//
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
Marshall Clow568bd022015-07-23 18:27:51 +000010// <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>
Marshall Clow568bd022015-07-23 18:27:51 +000019
20static 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
31int 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}