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.
30 using NUnit.Framework;
33 using System.Reflection;
34 using System.Security;
35 using System.Security.Permissions;
36 using System.Text.RegularExpressions;
38 namespace MonoCasTests.System.Text.RegularExpressions {
40 class TestRegexRunner : RegexRunner {
42 public TestRegexRunner ()
46 protected override bool FindFirstChar ()
51 protected override void Go ()
55 protected override void InitTrackCount ()
59 // easier to test from inside
62 // abstract (and protected) stuff
63 Assert.IsFalse (this.FindFirstChar (), "FindFirstChar");
68 Assert.IsNull (runcrawl, "runcrawl");
69 runcrawl = new int[3] { 0, 0, 0 };
70 Assert.AreEqual (0, runcrawlpos, "runcrawlpos");
72 Assert.IsNull (runmatch, "runmatch");
73 runmatch = Match.Empty;
74 Assert.IsNull (runregex, "runregex");
75 runregex = new Regex (String.Empty);
76 Assert.IsNull (runstack, "runstack");
77 runstack = new int[3] { 0, 0, 0 };
78 Assert.AreEqual (0, runstackpos, "runstackpos");
80 Assert.IsNull (runtext, "runtext");
82 Assert.AreEqual (0, runtextbeg, "runtextbeg");
84 Assert.AreEqual (0, runtextend, "runtextend");
86 Assert.AreEqual (0, runtextpos, "runtextpos");
88 Assert.AreEqual (0, runtextstart, "runtextstart");
90 Assert.IsNull (runtrack, "runtrack");
91 runtrack = new int[3] { 0, 0, 0 };
92 Assert.AreEqual (0, runtrackcount, "runtrackcount");
94 Assert.AreEqual (0, runtrackpos, "runtrackpos");
98 Assert.IsTrue (CharInSet ('a', "a", ""), "CharInSet");
100 Assert.AreEqual (4, Crawlpos (), "Crawlpos");
105 Assert.IsFalse (IsBoundary (0, 0, 0), "IsBoundary");
106 Assert.IsFalse (IsECMABoundary (0, 0, 0), "IsECMABoundary");
107 Assert.IsTrue (IsMatched (0), "IsMatched");
108 Assert.AreEqual (0, MatchIndex (0), "MatchIndex");
109 Assert.AreEqual (0, MatchLength (0), "MatchLength");
110 Assert.AreEqual (1, Popcrawl (), "Popcrawl");
111 TransferCapture (0, 0, 0, 0);
113 Assert.IsNotNull (Scan (new Regex (String.Empty), "mono", 0, 0, 0, 0, true), "Scan");
115 Assert.IsTrue (CharInSet ('a', "a", String.Empty), "CharInSet");
122 public class RegexRunnerCas {
127 if (!SecurityManager.SecurityEnabled)
128 Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
132 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
133 [Category ("NotWorking")]
134 public void Deny_Unrestricted ()
136 TestRegexRunner runner = new TestRegexRunner ();
141 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
142 public void LinkDemand_Deny_Unrestricted ()
144 ConstructorInfo ci = typeof (TestRegexRunner).GetConstructor (new Type[0]);
145 Assert.IsNotNull (ci, "default .ctor");
146 Assert.IsNotNull (ci.Invoke (null), "invoke");