Howard Hinnant | 853aff8 | 2010-06-25 20:56:08 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. 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 | // basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); |
| 15 | |
Howard Hinnant | e5561b0 | 2010-06-29 18:37:43 +0000 | [diff] [blame] | 16 | #include <iostream> |
| 17 | |
Howard Hinnant | 853aff8 | 2010-06-25 20:56:08 +0000 | [diff] [blame] | 18 | #include <regex> |
| 19 | #include <cassert> |
| 20 | |
| 21 | template <class CharT> |
| 22 | void |
| 23 | test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc) |
| 24 | { |
| 25 | std::basic_regex<CharT> r(p, f); |
| 26 | assert(r.flags() == f); |
| 27 | assert(r.mark_count() == mc); |
| 28 | } |
| 29 | |
| 30 | int main() |
| 31 | { |
Howard Hinnant | 853aff8 | 2010-06-25 20:56:08 +0000 | [diff] [blame] | 32 | test("\\(a\\)", std::regex_constants::basic, 1); |
| 33 | test("\\(a[bc]\\)", std::regex_constants::basic, 1); |
| 34 | test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2); |
| 35 | test("(a([bc]))", std::regex_constants::basic, 0); |
Howard Hinnant | 3d87b69 | 2010-08-12 21:14:20 +0000 | [diff] [blame^] | 36 | |
| 37 | test("\\(a\\)", std::regex_constants::extended, 0); |
| 38 | test("\\(a[bc]\\)", std::regex_constants::extended, 0); |
| 39 | test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0); |
| 40 | test("(a([bc]))", std::regex_constants::extended, 2); |
| 41 | |
| 42 | test("\\(a\\)", std::regex_constants::ECMAScript, 0); |
| 43 | test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0); |
| 44 | test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0); |
| 45 | test("(a([bc]))", std::regex_constants::ECMAScript, 2); |
| 46 | |
| 47 | test("\\(a\\)", std::regex_constants::awk, 0); |
| 48 | test("\\(a[bc]\\)", std::regex_constants::awk, 0); |
| 49 | test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0); |
| 50 | test("(a([bc]))", std::regex_constants::awk, 2); |
| 51 | |
| 52 | test("\\(a\\)", std::regex_constants::grep, 1); |
| 53 | test("\\(a[bc]\\)", std::regex_constants::grep, 1); |
| 54 | test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2); |
| 55 | test("(a([bc]))", std::regex_constants::grep, 0); |
| 56 | |
| 57 | test("\\(a\\)", std::regex_constants::egrep, 0); |
| 58 | test("\\(a[bc]\\)", std::regex_constants::egrep, 0); |
| 59 | test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0); |
| 60 | test("(a([bc]))", std::regex_constants::egrep, 2); |
Howard Hinnant | 853aff8 | 2010-06-25 20:56:08 +0000 | [diff] [blame] | 61 | } |