3 using System.Text.RegularExpressions;
6 namespace MonoTests.System.Text.RegularExpressions
9 public class RegexResultTests
14 public string original, pattern, replacement, expected;
15 public testcase (string o, string p, string r, string e) {
21 public void Execute () {
24 Match match = Regex.Match (original, pattern);
25 result = match.Result (replacement);
30 Assert.AreEqual (expected, result, "rr#: {0} ~ s,{1},{2},",
31 original, pattern, replacement);
35 static testcase [] tests = {
36 // original pattern replacement expected
37 new testcase ("F2345678910L71", @"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", "${S}$11$1", "Error." ),//0
38 new testcase ("F2345678910LL1", @"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", "${S}$11$1", "${S}LF" ),//1
39 new testcase ("texts", "(?<foo>e)(x)", "${foo}$1$2$&", "exeex" ),//2
40 new testcase ("texts", "(?<foo>e)(x)", "${foo}$1$2$_", "exetexts" ),//3
41 new testcase ("texts", "(?<foo>e)(x)", "${foo}$1$2$`", "exet" ),//4
42 new testcase ("texts", "(?<foo>e)(x)", "${foo}$1$2$'", "exets" ),//5
43 new testcase ("text", "x", "y", "y" ),//6
44 new testcase ("text", "x", "$", "$" ),//7
45 new testcase ("text", "x", "$1", "$1" ),//8
46 new testcase ("text", "x", "${1}", "${1}" ),//9
47 new testcase ("text", "x", "$5", "$5" ),//10
48 new testcase ("te(x)t", "x", "$5", "$5" ),//11
49 new testcase ("text", "x", "${5", "${5" ),//12
50 new testcase ("text", "x", "${foo", "${foo" ),//13
51 new testcase ("text", "(x)", "$5", "$5" ),//14
52 new testcase ("text", "(x)", "$1", "x" ),//15
53 new testcase ("text", "e(x)", "$1", "x" ),//16
54 new testcase ("text", "e(x)", "$5", "$5" ),//17
55 new testcase ("text", "e(x)", "$4", "$4" ),//18
56 new testcase ("text", "e(x)", "$3", "$3" ),//19
57 new testcase ("text", "e(x)", "${1}", "x" ),//20
58 new testcase ("text", "e(x)", "${3}", "${3}" ),//21
59 new testcase ("text", "e(x)", "${1}${3}", "x${3}" ),//22
60 new testcase ("text", "e(x)", "${1}${name}", "x${name}" ),//23
61 new testcase ("text", "e(?<foo>x)", "${1}${name}", "x${name}" ),//24
62 new testcase ("text", "e(?<foo>x)", "${1}${foo}", "xx" ),//25
63 new testcase ("text", "e(?<foo>x)", "${goll}${foo}", "${goll}x" ),//26
64 new testcase ("text", "e(?<foo>x)", "${goll${foo}", "${gollx" ),//27
65 new testcase ("text", "e(?<foo>x)", "${goll${foo}}", "${gollx}" ),//28
66 new testcase ("text", "e(?<foo>x)", "$${foo}}", "${foo}}" ),//29
67 new testcase ("text", "e(?<foo>x)", "${${foo}}", "${x}" ),//30
68 new testcase ("text", "e(?<foo>x)", "$${foo}}", "${foo}}" ),//31
69 new testcase ("text", "e(?<foo>x)", "$${bfoo}}", "${bfoo}}" ),//32
70 new testcase ("text", "e(?<foo>x)", "$${foo}}", "${foo}}" ),//33
71 new testcase ("text", "e(?<foo>x)", "$${foo}", "${foo}" ),//34
72 new testcase ("text", "e(?<foo>x)", "$$", "$" ),//35
73 new testcase ("text", "(?<foo>e)(?<foo>x)", "${foo}$1$2", "xx$2" ),//36
74 new testcase ("text", "(e)(?<foo>x)", "${foo}$1$2", "xex" ),//37
75 new testcase ("text", "(?<foo>e)(x)", "${foo}$1$2", "exe" ),//38
76 new testcase ("text", "(e)(?<foo>x)", "${foo}$1$2$+", "xexx" ),//39
77 new testcase ("text", "(?<foo>e)(x)", "${foo}$1$2$+", "exee" ),//40
78 new testcase ("314 1592 65358", @"\d\d\d\d|\d\d\d", "a", "a" ),//41
79 new testcase ("2 314 1592 65358", @"\d\d\d\d|\d\d\d", "a", "a" ),//42
80 new testcase ("<i>am not</i>", "<(.+?)>", "[$0:$1]", "[<i>:i]"),//43
81 new testcase ("F2345678910L71", @"(F)(2)(3)(4)(5)(6)(?<S>7)(8)(9)(10)(L)\11", "${S}$11$1", "77F" ),//44
82 new testcase ("a", "a", @"\\", @"\\"), // bug #317092 //45
86 public void ResultTest_000 () {
90 public void ResultTest_001 () {
94 public void ResultTest_002 () {
98 public void ResultTest_003 () {
102 public void ResultTest_004 () {
103 tests [4].Execute ();
106 public void ResultTest_005 () {
107 tests [5].Execute ();
110 public void ResultTest_006 () {
111 tests [6].Execute ();
114 public void ResultTest_007 () {
115 tests [7].Execute ();
118 public void ResultTest_008 () {
119 tests [8].Execute ();
122 public void ResultTest_009 () {
123 tests [9].Execute ();
126 public void ResultTest_010 () {
127 tests [10].Execute ();
130 public void ResultTest_011 () {
131 tests [11].Execute ();
134 public void ResultTest_012 () {
135 tests [12].Execute ();
138 public void ResultTest_013 () {
139 tests [13].Execute ();
142 public void ResultTest_014 () {
143 tests [14].Execute ();
146 public void ResultTest_015 () {
147 tests [15].Execute ();
150 public void ResultTest_016 () {
151 tests [16].Execute ();
154 public void ResultTest_017 () {
155 tests [17].Execute ();
158 public void ResultTest_018 () {
159 tests [18].Execute ();
162 public void ResultTest_019 () {
163 tests [19].Execute ();
166 public void ResultTest_020 () {
167 tests [20].Execute ();
170 public void ResultTest_021 () {
171 tests [21].Execute ();
174 public void ResultTest_022 () {
175 tests [22].Execute ();
178 public void ResultTest_023 () {
179 tests [23].Execute ();
182 public void ResultTest_024 () {
183 tests [24].Execute ();
186 public void ResultTest_025 () {
187 tests [25].Execute ();
190 public void ResultTest_026 () {
191 tests [26].Execute ();
194 public void ResultTest_027 () {
195 tests [27].Execute ();
198 public void ResultTest_028 () {
199 tests [28].Execute ();
202 public void ResultTest_029 () {
203 tests [29].Execute ();
206 public void ResultTest_030 () {
207 tests [30].Execute ();
210 public void ResultTest_031 () {
211 tests [31].Execute ();
214 public void ResultTest_032 () {
215 tests [32].Execute ();
218 public void ResultTest_033 () {
219 tests [33].Execute ();
222 public void ResultTest_034 () {
223 tests [34].Execute ();
226 public void ResultTest_035 () {
227 tests [35].Execute ();
230 public void ResultTest_036 () {
231 tests [36].Execute ();
234 public void ResultTest_037 () {
235 tests [37].Execute ();
238 public void ResultTest_038 () {
239 tests [38].Execute ();
242 public void ResultTest_039 () {
243 tests [39].Execute ();
246 public void ResultTest_040 () {
247 tests [40].Execute ();
250 public void ResultTest_041 () {
251 tests [41].Execute ();
254 public void ResultTest_042 () {
255 tests [42].Execute ();
258 public void ResultTest_043 () {
259 tests [43].Execute ();
262 [Category("NotWorking")]
263 public void ResultTest_044 () {
264 tests [44].Execute ();
267 public void ResultTest_045 () {
268 tests [45].Execute ();