| 1 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // test6.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 | // |
|---|
| 13 | template<typename BidiIterT> |
|---|
| 14 | boost::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 | "test103" |
|---|
| 26 | , L("a\nxb\n") |
|---|
| 27 | , regex_type(~before(bol) >> L('x')) |
|---|
| 28 | , no_match |
|---|
| 29 | ) |
|---|
| 30 | , test_case |
|---|
| 31 | ( |
|---|
| 32 | "test104" |
|---|
| 33 | , L("a\nxb\n") |
|---|
| 34 | , regex_type(~before(bos) >> L('x')) |
|---|
| 35 | , backrefs(L("x"), nilbr) |
|---|
| 36 | ) |
|---|
| 37 | , test_case |
|---|
| 38 | ( |
|---|
| 39 | "test105" |
|---|
| 40 | , L("a\nxb\n") |
|---|
| 41 | , regex_type(~before(bos) >> L('x')) |
|---|
| 42 | , backrefs(L("x"), nilbr) |
|---|
| 43 | ) |
|---|
| 44 | , test_case |
|---|
| 45 | ( |
|---|
| 46 | "test106" |
|---|
| 47 | , L("(this)") |
|---|
| 48 | , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos) |
|---|
| 49 | , backrefs(L("(this)"), L(""), L(""), nilbr) |
|---|
| 50 | ) |
|---|
| 51 | , test_case |
|---|
| 52 | ( |
|---|
| 53 | "test107" |
|---|
| 54 | , L("this") |
|---|
| 55 | , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos) |
|---|
| 56 | , backrefs(L("this"), L(""), L(""), nilbr) |
|---|
| 57 | ) |
|---|
| 58 | , test_case |
|---|
| 59 | ( |
|---|
| 60 | "test108" |
|---|
| 61 | , L("this)") |
|---|
| 62 | , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos) |
|---|
| 63 | , no_match |
|---|
| 64 | ) |
|---|
| 65 | , test_case |
|---|
| 66 | ( |
|---|
| 67 | "test109" |
|---|
| 68 | , L("(this") |
|---|
| 69 | , regex_type(bos >> (L('(') >> (s1= nil) | (s2= nil)) >> +_w >> (L(')') >> s1 | s2) >> eos) |
|---|
| 70 | , no_match |
|---|
| 71 | ) |
|---|
| 72 | , test_case |
|---|
| 73 | ( |
|---|
| 74 | "test110" |
|---|
| 75 | , L("abba123abba") |
|---|
| 76 | , regex_type(+~alpha) |
|---|
| 77 | , backrefs(L("123"), nilbr) |
|---|
| 78 | ) |
|---|
| 79 | , test_case |
|---|
| 80 | ( |
|---|
| 81 | "test111" |
|---|
| 82 | , L("abba123abba") |
|---|
| 83 | , regex_type(+set[alpha | ~alpha]) |
|---|
| 84 | , backrefs(L("abba123abba"), nilbr) |
|---|
| 85 | ) |
|---|
| 86 | , test_case |
|---|
| 87 | ( |
|---|
| 88 | "test112" |
|---|
| 89 | , L("123abba123") |
|---|
| 90 | , regex_type(+~set[~alpha]) |
|---|
| 91 | , backrefs(L("abba"), nilbr) |
|---|
| 92 | ) |
|---|
| 93 | //, test_case |
|---|
| 94 | // ( |
|---|
| 95 | // "test113" |
|---|
| 96 | // , L("123abba123") |
|---|
| 97 | // , regex_type(as_xpr(L("[[:alpha:]\\y]+"))) |
|---|
| 98 | // , backrefs(L("123abba123"), nilbr) |
|---|
| 99 | // ) |
|---|
| 100 | , test_case |
|---|
| 101 | ( |
|---|
| 102 | "test114" |
|---|
| 103 | , L("abba123abba") |
|---|
| 104 | , regex_type(+~set[~alnum | ~digit]) |
|---|
| 105 | , backrefs(L("123"), nilbr) |
|---|
| 106 | ) |
|---|
| 107 | , test_case |
|---|
| 108 | ( |
|---|
| 109 | "test115" |
|---|
| 110 | , L("aaaaA") |
|---|
| 111 | , regex_type(icase(bos >> repeat<4>(s1= L('a') >> !s1) >> eos)) |
|---|
| 112 | , backrefs(L("aaaaA"), L("A"), nilbr) |
|---|
| 113 | ) |
|---|
| 114 | , test_case |
|---|
| 115 | ( |
|---|
| 116 | "test116" |
|---|
| 117 | , L("aaaaAa") |
|---|
| 118 | , regex_type(icase(bos >> repeat<4>(s1= L('a') >> !s1) >> eos)) |
|---|
| 119 | , backrefs(L("aaaaAa"), L("Aa"), nilbr) |
|---|
| 120 | ) |
|---|
| 121 | }; |
|---|
| 122 | |
|---|
| 123 | return boost::make_iterator_range(test_cases); |
|---|
| 124 | } |
|---|