1878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//===----------------------------------------------------------------------===//
2878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//
3878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//                     The LLVM Compiler Infrastructure
4878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//
8878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//===----------------------------------------------------------------------===//
9878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
10878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant// <regex>
11878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
12878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant// template <class charT, class traits = regex_traits<charT>> class basic_regex;
13878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
14878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant// template <class ST, class SA>
15878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//    basic_regex(const basic_string<charT, ST, SA>& s,
16878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//                flag_type f = regex_constants::ECMAScript);
17878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
18878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant#include <regex>
19878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant#include <cassert>
20878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
21878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnanttemplate <class String>
22878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnantvoid
23878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnanttest(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
24878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant{
25878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::basic_regex<typename String::value_type> r(p, f);
26878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    assert(r.flags() == f);
27878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    assert(r.mark_count() == mc);
28878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant}
29878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
30878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnantint main()
31878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant{
32878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
33878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
34878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
35878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
36878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
37878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
38878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
39878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
40878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
41878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
42878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
43878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
44878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
45878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
46878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
47878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
48878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
49878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
50878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
51878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
52878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
53878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
54878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
55878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
56878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
57878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
58878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
59878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
60878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
61878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant}
62