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 ForwardIterator>
15878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//    basic_regex(ForwardIterator first, ForwardIterator last,
16878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant//                flag_type f = regex_constants::ECMAScript);
17878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
18878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant#include <regex>
19878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant#include <cassert>
20878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
2183e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "test_iterators.h"
22878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
23878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnanttemplate <class Iter>
24878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnantvoid
25878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnanttest(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
26878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant{
27878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
28878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    assert(r.flags() == f);
29878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    assert(r.mark_count() == mc);
30878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant}
31878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
32878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnantint main()
33878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant{
34878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    typedef forward_iterator<std::string::const_iterator> F;
35878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::string s1("\\(a\\)");
36878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::string s2("\\(a[bc]\\)");
37878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::string s3("\\(a\\([bc]\\)\\)");
38878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    std::string s4("(a([bc]))");
39878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
40878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
41878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
42878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
43878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
44878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
45878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
46878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
47878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
48878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
49878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
50878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
51878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
52878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
53878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
54878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
55878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
56878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
57878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
58878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
59878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
60878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
61878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
62878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
63878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
64878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant
65878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
66878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
67878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
68878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant    test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
69878465043ff69cb10c3e65385c31384ef853d9abHoward Hinnant}
70