Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/xpressive/test/test3.hpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 5.4 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2// test3.hpp
3//
4//  Copyright 2004 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//
13template<typename BidiIterT>
14boost::iterator_range<test_case<BidiIterT> const *> get_test_cases()
15{
16    typedef typename boost::iterator_value<BidiIterT>::type char_type;
17    typedef test_case<BidiIterT> test_case;
18    typedef basic_regex<BidiIterT> regex_type;
19
20    static char_type const *nilbr = 0;
21    static test_case const test_cases[] =
22    {
23        test_case
24        (
25            "test41"
26          , L("foobarFOObarfoo")
27          , regex_type((s1= icase(L("FOO"))) >> (s2= -*_) >> s1)
28          , backrefs(L("foobarFOObarfoo"), L("foo"), L("barFOObar"), nilbr)
29        )
30      , test_case
31        (
32            "test42"
33          , L("foobarFOObarfoo")
34          , regex_type((s1= icase(L("FOO"))) >> (s2= -*_) >> icase(s1))
35          , backrefs(L("foobarFOO"), L("foo"), L("bar"), nilbr)
36        )
37      , test_case
38        (
39            "test42.1"
40          , L("fooFOOOFOOOOObar")
41          , regex_type(+(s1= L("foo") | icase(s1 >> L('O'))))
42          , backrefs(L("fooFOOOFOOOO"), L("FOOOO"), nilbr)
43        )
44      , test_case
45        (
46            "test43"
47          , L("zoo")
48          , regex_type(bos >> set[range(L('A'),L('Z')) | range(L('a'),L('m'))])
49          , no_match
50        )
51      , test_case
52        (
53            "test44"
54          , L("Here is a URL: http://www.cnn.com. OK?")
55          , regex_type((s1= L("http") >> !as_xpr(L('s')) >> L(":/") | L("www."))
56                        >> +set[_w | (set=L('.'),L('/'),L(','),L('?'),L('@'),L('#'),L('%'),L('!'),L('_'),L('='),L('~'),L('&'),L('-'))]
57                        >> _w)
58          , backrefs(L("http://www.cnn.com"), L("http:/"), nilbr)
59        )
60      , test_case
61        (
62            "test45"
63          , L("fooooooooo")
64          , regex_type(L('f') >> repeat<2,5>(L('o')))
65          , backrefs(L("fooooo"), nilbr)
66        )
67      , test_case
68        (
69            "test46"
70          , L("fooooooooo")
71          , regex_type(L('f') >> -repeat<2,5>(L('o')))
72          , backrefs(L("foo"), nilbr)
73        )
74      , test_case
75        (
76            "test45.1"
77          , L("fooooooooo")
78          , regex_type(L('f') >> repeat<2,5>(L('o')) >> L('o'))
79          , backrefs(L("foooooo"), nilbr)
80        )
81      , test_case
82        (
83            "test46.1"
84          , L("fooooooooo")
85          , regex_type(L('f') >> -repeat<2,5>(L('o')) >> L('o'))
86          , backrefs(L("fooo"), nilbr)
87        )
88      , test_case
89        (
90            "test47"
91          , L("{match this}")
92          , regex_type(bos >> L('{') >> *_ >> L('}') >> eos)
93          , backrefs(L("{match this}"), nilbr)
94        )
95      , test_case
96        (
97            "test48"
98          , L("+-+-")
99          , regex_type(+(set=L('+'),L('-')))
100          , backrefs(L("+-+-"), nilbr)
101        )
102      , test_case
103        (
104            "test49"
105          , L("+-+-")
106          , regex_type(+(set=L('-'),L('+')))
107          , backrefs(L("+-+-"), nilbr)
108        )
109      , test_case
110        (
111            "test50"
112          , L("\\05g-9e")
113          , regex_type(+set[_d | L('-') | L('g')])
114          , backrefs(L("05g-9"), nilbr)
115        )
116      , test_case
117        (
118            "test51"
119          , L("\\05g-9e")
120          , regex_type(+set[_d | L('-') | L('g')])
121          , backrefs(L("05g-9"), nilbr)
122        )
123      , test_case
124        (
125            "test52"
126          , L("\\05g-9e")
127          , regex_type(+set[L('g') | as_xpr(L('-')) | _d])
128          , backrefs(L("05g-9"), nilbr)
129        )
130      , test_case
131        (
132            "test53"
133          , L("\\05g-9e")
134          , regex_type(+set[L('g') | as_xpr(L('-')) | _d])
135          , backrefs(L("05g-9"), nilbr)
136        )
137      , test_case
138        (
139            "test54"
140          , L("aBcdefg\\")
141          , regex_type(icase(+range(L('a'),L('g'))))
142          , backrefs(L("aBcdefg"), nilbr)
143        )
144      , test_case
145        (
146            "test55"
147          , L("ab/.-ba")
148          , regex_type(+range(L('-'),L('/')))
149          , backrefs(L("/.-"), nilbr)
150        )
151      , test_case
152        (
153            "test56"
154          , L("ab+,-ba")
155          , regex_type(+range(L('+'),L('-')))
156          , backrefs(L("+,-"), nilbr)
157        )
158      , test_case
159        (
160            "test56.1"
161          , L("aaabbbb----")
162          , regex_type(+range(L('b'),L('b')))
163          , backrefs(L("bbbb"), nilbr)
164        )
165      , test_case
166        (
167            "test57"
168          , L("foobarFOO5")
169          , regex_type(icase((s1= L("foo")) >> *_ >> L('\15')))
170          , no_match
171        )
172      , test_case
173        (
174            "test58"
175          , L("Her number is 804-867-5309.")
176          , regex_type(repeat<2>(repeat<3>(_d) >> L('-')) >> repeat<4>(_d))
177          , backrefs(L("804-867-5309"), nilbr)
178        )
179      , test_case
180        (
181            "test59"
182          , L("foo")
183          , regex_type(L('f') >> +as_xpr(L('o')))
184          , backrefs(L("foo"), nilbr)
185        )
186      , test_case
187        (
188            "test60"
189          , L("fooFOObar")
190          , regex_type(icase(+(s1= L("foo")) >> L("foobar")))
191          , backrefs(L("fooFOObar"), L("foo"), nilbr)
192        )
193    };
194
195    return boost::make_iterator_range(test_cases);
196}
Note: See TracBrowser for help on using the repository browser.