File: RegexResultTests.cs

package info (click to toggle)
mono-reference-assemblies 3.12.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 604,240 kB
  • ctags: 625,505
  • sloc: cs: 3,967,741; xml: 2,793,081; ansic: 418,042; java: 60,435; sh: 14,833; makefile: 11,576; sql: 7,956; perl: 1,467; cpp: 1,446; yacc: 1,203; python: 598; asm: 422; sed: 16; php: 1
file content (179 lines) | stat: -rw-r--r-- 7,103 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using System;
using System.Text;
using System.Text.RegularExpressions;
using NUnit.Framework;

namespace MonoTests.System.Text.RegularExpressions
{
	[TestFixture]
	public class RegexResultTests
	{

		struct testcase
		{
			public string original, pattern, replacement, expected;
			public testcase (string o, string p, string r, string e) {
				original = o;
				pattern = p;
				replacement = r;
				expected = e;
			}
			public void Execute () {
				string result;
				try {
					Match match = Regex.Match (original, pattern);
					result = match.Result (replacement);
				}
				catch (Exception) {
					result = "Error.";
				}
				Assert.AreEqual (expected, result, "rr#: {0} ~ s,{1},{2},",
					original, pattern, replacement);

			}
		}
		static testcase [] tests = {
			//	original 	pattern			replacement		expected
			new testcase ("F2345678910L71",	@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", 	"${S}$11$1", "Error." 	),//0
			new testcase ("F2345678910LL1",	@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", 	"${S}$11$1", "${S}LF" 	),//1
			new testcase ("texts",	"(?<foo>e)(x)", 	"${foo}$1$2$&",		"exeex" 	),//2
			new testcase ("texts",	"(?<foo>e)(x)", 	"${foo}$1$2$_",		"exetexts" 	),//3
			new testcase ("texts",	"(?<foo>e)(x)", 	"${foo}$1$2$`",		"exet" 	),//4
			new testcase ("texts",	"(?<foo>e)(x)", 	"${foo}$1$2$'",		"exets" 	),//5
			new testcase ("text",	"x",			"y",			"y"		),//6
			new testcase ("text",	"x",			"$",			"$"		),//7
			new testcase ("text",	"x",			"$1",			"$1"		),//8
			new testcase ("text",	"x",			"${1}",			"${1}"	),//9
			new testcase ("text",	"x",			"$5",			"$5"		),//10
			new testcase ("te(x)t",	"x",			"$5",			"$5"	),//11
			new testcase ("text",	"x",			"${5",			"${5"	),//12
			new testcase ("text",	"x",			"${foo",		"${foo"	),//13
			new testcase ("text",	"(x)",			"$5",			"$5"		),//14
			new testcase ("text",	"(x)",			"$1",			"x"		),//15
			new testcase ("text",	"e(x)",			"$1",			"x"		),//16
			new testcase ("text",	"e(x)",			"$5",			"$5"		),//17
			new testcase ("text",	"e(x)",			"$4",			"$4"		),//18
			new testcase ("text",	"e(x)",			"$3",			"$3"		),//19
			new testcase ("text",	"e(x)",			"${1}",			"x"		),//20
			new testcase ("text",	"e(x)",			"${3}",			"${3}"	),//21
			new testcase ("text",	"e(x)",			"${1}${3}",		"x${3}"	),//22
			new testcase ("text",	"e(x)",			"${1}${name}",		"x${name}"	),//23
			new testcase ("text",	"e(?<foo>x)",		"${1}${name}",		"x${name}"	),//24
			new testcase ("text",	"e(?<foo>x)",		"${1}${foo}",		"xx"		),//25
			new testcase ("text",	"e(?<foo>x)",		"${goll}${foo}",	"${goll}x"	),//26
			new testcase ("text",	"e(?<foo>x)",		"${goll${foo}",		"${gollx"	),//27
			new testcase ("text",	"e(?<foo>x)",		"${goll${foo}}",	"${gollx}"	),//28
			new testcase ("text",	"e(?<foo>x)",		"$${foo}}",		"${foo}}"	),//29
			new testcase ("text",	"e(?<foo>x)",		"${${foo}}",		"${x}"	),//30
			new testcase ("text",	"e(?<foo>x)",		"$${foo}}",		"${foo}}"	),//31
			new testcase ("text",	"e(?<foo>x)",		"$${bfoo}}",		"${bfoo}}"	),//32
			new testcase ("text",	"e(?<foo>x)",		"$${foo}}",		"${foo}}"	),//33
			new testcase ("text",	"e(?<foo>x)",		"$${foo}",		"${foo}"	),//34
			new testcase ("text",	"e(?<foo>x)",		"$$",			"$"		),//35
			new testcase ("text",	"(?<foo>e)(?<foo>x)", 	"${foo}$1$2",		"xx$2" 	),//36
			new testcase ("text",	"(e)(?<foo>x)", 	"${foo}$1$2",		"xex" 	),//37
			new testcase ("text",	"(?<foo>e)(x)", 	"${foo}$1$2",		"exe" 	),//38
			new testcase ("text",	"(e)(?<foo>x)", 	"${foo}$1$2$+",		"xexx" 	),//39
			new testcase ("text",	"(?<foo>e)(x)", 	"${foo}$1$2$+",		"exee" 	),//40
			new testcase ("314 1592 65358",		@"\d\d\d\d|\d\d\d", "a",	"a"	),//41
			new testcase ("2 314 1592 65358", 	@"\d\d\d\d|\d\d\d", "a",	"a"	),//42
			new testcase ("<i>am not</i>", 		"<(.+?)>", 	"[$0:$1]",	"[<i>:i]"),//43
			new testcase ("F2345678910L71",	@"(F)(2)(3)(4)(5)(6)(?<S>7)(8)(9)(10)(L)\11", 	"${S}$11$1", "77F" 	),//44
			new testcase ("a", "a", @"\\", @"\\"), // bug #317092 //45
		};

		[Test]
		public void ResultTest_000 () { tests [0].Execute (); }
		[Test]
		public void ResultTest_001 () { tests [1].Execute (); }
		[Test]
		public void ResultTest_002 () { tests [2].Execute (); }
		[Test]
		public void ResultTest_003 () { tests [3].Execute (); }
		[Test]
		public void ResultTest_004 () { tests [4].Execute (); }
		[Test]
		public void ResultTest_005 () { tests [5].Execute (); }
		[Test]
		public void ResultTest_006 () { tests [6].Execute (); }
		[Test]
		public void ResultTest_007 () { tests [7].Execute (); }
		[Test]
		public void ResultTest_008 () { tests [8].Execute (); }
		[Test]
		public void ResultTest_009 () { tests [9].Execute (); }
		[Test]
		public void ResultTest_010 () { tests [10].Execute (); }
		[Test]
		public void ResultTest_011 () { tests [11].Execute (); }
		[Test]
		public void ResultTest_012 () { tests [12].Execute (); }
		[Test]
		public void ResultTest_013 () { tests [13].Execute (); }
		[Test]
		public void ResultTest_014 () { tests [14].Execute (); }
		[Test]
		public void ResultTest_015 () { tests [15].Execute (); }
		[Test]
		public void ResultTest_016 () { tests [16].Execute (); }
		[Test]
		public void ResultTest_017 () { tests [17].Execute (); }
		[Test]
		public void ResultTest_018 () { tests [18].Execute (); }
		[Test]
		public void ResultTest_019 () { tests [19].Execute (); }
		[Test]
		public void ResultTest_020 () { tests [20].Execute (); }
		[Test]
		public void ResultTest_021 () { tests [21].Execute (); }
		[Test]
		public void ResultTest_022 () { tests [22].Execute (); }
		[Test]
		public void ResultTest_023 () { tests [23].Execute (); }
		[Test]
		public void ResultTest_024 () { tests [24].Execute (); }
		[Test]
		public void ResultTest_025 () { tests [25].Execute (); }
		[Test]
		public void ResultTest_026 () { tests [26].Execute (); }
		[Test]
		public void ResultTest_027 () { tests [27].Execute (); }
		[Test]
		public void ResultTest_028 () { tests [28].Execute (); }
		[Test]
		public void ResultTest_029 () { tests [29].Execute (); }
		[Test]
		public void ResultTest_030 () { tests [30].Execute (); }
		[Test]
		public void ResultTest_031 () { tests [31].Execute (); }
		[Test]
		public void ResultTest_032 () { tests [32].Execute (); }
		[Test]
		public void ResultTest_033 () { tests [33].Execute (); }
		[Test]
		public void ResultTest_034 () { tests [34].Execute (); }
		[Test]
		public void ResultTest_035 () { tests [35].Execute (); }
		[Test]
		public void ResultTest_036 () { tests [36].Execute (); }
		[Test]
		public void ResultTest_037 () { tests [37].Execute (); }
		[Test]
		public void ResultTest_038 () { tests [38].Execute (); }
		[Test]
		public void ResultTest_039 () { tests [39].Execute (); }
		[Test]
		public void ResultTest_040 () { tests [40].Execute (); }
		[Test]
		public void ResultTest_041 () { tests [41].Execute (); }
		[Test]
		public void ResultTest_042 () { tests [42].Execute (); }
		[Test]
		public void ResultTest_043 () { tests [43].Execute (); }
		[Test]
		[Category("NotWorking")]
		public void ResultTest_044 () { tests [44].Execute (); }
		[Test]
		public void ResultTest_045 () { tests [45].Execute (); }
	}
}