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// basic_regex(const charT* p, size_t len, flag_type f);
15878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
16878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant#include <regex>
17878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant#include <cassert>
18878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
19878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnanttemplate <class CharT>
20878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnantvoid
21878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnanttest(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f,
22878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant     unsigned mc)
23878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant{
24878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::basic_regex<CharT> r(p, len, f);
25878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    assert(r.flags() == f);
26878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    assert(r.mark_count() == mc);
27878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant}
28878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
29878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnantint main()
30878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant{
31878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\)", 5, std::regex_constants::basic, 1);
32878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
33878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::basic, 2);
34878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("(a([bc]))", 9, std::regex_constants::basic, 0);
35878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
36878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\)", 5, std::regex_constants::extended, 0);
37878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a[bc]\\)", 9, std::regex_constants::extended, 0);
38878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::extended, 0);
39878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("(a([bc]))", 9, std::regex_constants::extended, 2);
40878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
41878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\)", 5, std::regex_constants::ECMAScript, 0);
42878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a[bc]\\)", 9, std::regex_constants::ECMAScript, 0);
43878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::ECMAScript, 0);
44878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("(a([bc]))", 9, std::regex_constants::ECMAScript, 2);
45878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
46878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\)", 5, std::regex_constants::awk, 0);
47878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a[bc]\\)", 9, std::regex_constants::awk, 0);
48878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::awk, 0);
49878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("(a([bc]))", 9, std::regex_constants::awk, 2);
50878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
51878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\)", 5, std::regex_constants::grep, 1);
52878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a[bc]\\)", 9, std::regex_constants::grep, 1);
53878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::grep, 2);
54878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("(a([bc]))", 9, std::regex_constants::grep, 0);
55878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
56878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\)", 5, std::regex_constants::egrep, 0);
57878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
58878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
59878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test("(a([bc]))", 9, std::regex_constants::egrep, 2);
60878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant}
61