3 // - CAS unit tests for System.Text.RegularExpressions.RegexRunner
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using NUnit.Framework;
36 using System.Reflection;
37 using System.Security;
38 using System.Security.Permissions;
39 using System.Text.RegularExpressions;
41 namespace MonoCasTests.System.Text.RegularExpressions {
43 class TestRegexRunner : RegexRunner {
45 public TestRegexRunner ()
49 protected override bool FindFirstChar ()
54 protected override void Go ()
58 protected override void InitTrackCount ()
62 // easier to test from inside
65 // abstract (and protected) stuff
66 Assert.IsFalse (this.FindFirstChar (), "FindFirstChar");
71 Assert.IsNull (runcrawl, "runcrawl");
72 runcrawl = new int[3] { 0, 0, 0 };
73 Assert.AreEqual (0, runcrawlpos, "runcrawlpos");
75 Assert.IsNull (runmatch, "runmatch");
76 runmatch = Match.Empty;
77 Assert.IsNull (runregex, "runregex");
78 runregex = new Regex (String.Empty);
79 Assert.IsNull (runstack, "runstack");
80 runstack = new int[3] { 0, 0, 0 };
81 Assert.AreEqual (0, runstackpos, "runstackpos");
83 Assert.IsNull (runtext, "runtext");
85 Assert.AreEqual (0, runtextbeg, "runtextbeg");
87 Assert.AreEqual (0, runtextend, "runtextend");
89 Assert.AreEqual (0, runtextpos, "runtextpos");
91 Assert.AreEqual (0, runtextstart, "runtextstart");
93 Assert.IsNull (runtrack, "runtrack");
94 runtrack = new int[3] { 0, 0, 0 };
95 Assert.AreEqual (0, runtrackcount, "runtrackcount");
97 Assert.AreEqual (0, runtrackpos, "runtrackpos");
101 Assert.IsTrue (CharInSet ('a', "a", ""), "CharInSet");
103 Assert.AreEqual (4, Crawlpos (), "Crawlpos");
108 Assert.IsFalse (IsBoundary (0, 0, 0), "IsBoundary");
109 Assert.IsFalse (IsECMABoundary (0, 0, 0), "IsECMABoundary");
110 Assert.IsTrue (IsMatched (0), "IsMatched");
111 Assert.AreEqual (0, MatchIndex (0), "MatchIndex");
112 Assert.AreEqual (0, MatchLength (0), "MatchLength");
113 Assert.AreEqual (1, Popcrawl (), "Popcrawl");
114 TransferCapture (0, 0, 0, 0);
116 Assert.IsNotNull (Scan (new Regex (String.Empty), "mono", 0, 0, 0, 0, true), "Scan");
117 Assert.IsTrue (CharInSet ('a', "a", String.Empty), "CharInSet");
123 public class RegexRunnerCas {
128 if (!SecurityManager.SecurityEnabled)
129 Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
133 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
134 [Category ("NotWorking")]
135 public void Deny_Unrestricted ()
137 TestRegexRunner runner = new TestRegexRunner ();
142 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
143 public void LinkDemand_Deny_Unrestricted ()
145 ConstructorInfo ci = typeof (TestRegexRunner).GetConstructor (new Type[0]);
146 Assert.IsNotNull (ci, "default .ctor");
147 Assert.IsNotNull (ci.Invoke (null), "invoke");