1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // test4.hpp |
3 | // |
4 | // Copyright 2008 Eric Niebler. Distributed under the Boost |
5 | // Software License, Version 1.0. (See accompanying file |
6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
7 | |
8 | #include "./test.hpp" |
9 | |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | // get_test_cases |
12 | // |
13 | template<typename BidiIterT> |
14 | boost::iterator_range<xpr_test_case<BidiIterT> const *> get_test_cases() |
15 | { |
16 | typedef typename boost::iterator_value<BidiIterT>::type char_type; |
17 | typedef xpr_test_case<BidiIterT> xpr_test_case; |
18 | typedef basic_regex<BidiIterT> regex_type; |
19 | |
20 | // for testing recursive static regexes |
21 | //regex_type parens = L('(') >> *( keep( +~(set=L('('),L(')')) ) | self ) >> L(')'); |
22 | |
23 | regex_type parens; |
24 | parens = L('(') >> *( keep( +~(set=L('('),L(')')) ) | by_ref(parens) ) >> L(')'); |
25 | |
26 | static char_type const *nilbr = 0; |
27 | static xpr_test_case const test_cases[] = |
28 | { |
29 | xpr_test_case |
30 | ( |
31 | "test61" |
32 | , L("this is sublist(now(is(the(time),for(all),good(men))to(come)))ok?" ) |
33 | , regex_type(_b >> L("sublist" ) >> parens) |
34 | , backrefs(L("sublist(now(is(the(time),for(all),good(men))to(come)))" ), nilbr) |
35 | ) |
36 | , xpr_test_case |
37 | ( |
38 | "test62" |
39 | , L("this is sublist(now(is(the(time),for(all),good(men))to(come))ok?" ) |
40 | , regex_type(_b >> L("sublist" ) >> parens) |
41 | , no_match |
42 | ) |
43 | , xpr_test_case |
44 | ( |
45 | "test63" |
46 | , L("foobar" ) |
47 | , regex_type(bos >> L("baz" ) | L("bar" )) |
48 | , backrefs(L("bar" ), nilbr) |
49 | ) |
50 | , xpr_test_case |
51 | ( |
52 | "test69" |
53 | , L("FooBarfoobar" ) |
54 | , regex_type(icase(*_ >> L("foo" ))) |
55 | , backrefs(L("FooBarfoo" ), nilbr) |
56 | ) |
57 | , xpr_test_case |
58 | ( |
59 | "test70" |
60 | , L("FooBarfoobar" ) |
61 | , regex_type(icase(*_ >> L("boo" ))) |
62 | , no_match |
63 | ) |
64 | , xpr_test_case |
65 | ( |
66 | "test71" |
67 | , L("FooBarfoobar" ) |
68 | , regex_type(icase(*_ >> L("boo" ) | L("bar" ))) |
69 | , backrefs(L("Bar" ), nilbr) |
70 | ) |
71 | , xpr_test_case |
72 | ( |
73 | "test72" |
74 | , L("FooBarfoobar" ) |
75 | , regex_type(icase(L("bar" ))) |
76 | , backrefs(L("Bar" ), nilbr) |
77 | ) |
78 | , xpr_test_case |
79 | ( |
80 | "test75" |
81 | , L("fooooo" ) |
82 | , regex_type(L('f') >> repeat<1,repeat_max>(L('o'))) |
83 | , backrefs(L("fooooo" ), nilbr) |
84 | ) |
85 | , xpr_test_case |
86 | ( |
87 | "test78" |
88 | , L("This (has) parens" ) |
89 | , regex_type(L("This " ) >> (s1= L("(has)" )) >> L(' ') >> (s2= L("parens" ))) |
90 | , backrefs(L("This (has) parens" ), L("(has)" ), L("parens" ), nilbr) |
91 | ) |
92 | , xpr_test_case |
93 | ( |
94 | "test79" |
95 | , L("This (has) parens" ) |
96 | , regex_type(as_xpr(L("This (has) parens" ))) |
97 | , backrefs(L("This (has) parens" ), nilbr) |
98 | ) |
99 | , xpr_test_case |
100 | ( |
101 | "test80" |
102 | , L("This (has) parens" ) |
103 | , regex_type(as_xpr(L("This (has) parens" ))) |
104 | , backrefs(L("This (has) parens" ), nilbr) |
105 | ) |
106 | }; |
107 | |
108 | return boost::make_iterator_range(test_cases); |
109 | } |
110 | |