+2007-11-01 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Match.cs: Do not throw NotSupportedException on zero-length
+ replacement argument.
+
2007-10-29 Arina Itkes <arinai@mainsoft.com>
* Regex.cs: Moving creation of Regex machine to ctor.
{
if (replacement == null)
throw new ArgumentNullException ("replacement");
- if (replacement.Length == 0)
- throw new NotSupportedException ();
if (machine == null)
throw new NotSupportedException ("Result cannot be called on failed Match.");
+2007-11-01 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * GroupTest.cs: Improved test for null argument check.
+ * MatchTest.cs: Improved tests for null argument checks. Added and
+ fixed replacement tests.
+ * RegexMatchTest.cs: Marked tests that do not pass on MS as NotDotNet.
+ Fixed expected result for trial 5.
+ * RegexResultTests.cs: Fixed Assert.
+
2007-10-29 Arina Itkes <arinai@mainsoft.com>
* RegexReplace.cs RegxMatchTests.cs RegexResultTests.cs
using System;
using System.Text.RegularExpressions;
-namespace MonoTests.System.Text.RegularExpressions {
-
+namespace MonoTests.System.Text.RegularExpressions
+{
[TestFixture]
- public class GroupTest {
-
+ public class GroupTest
+ {
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void Synchronized_Null ()
+ public void Synchronized_Inner_Null ()
{
- Group.Synchronized (null);
+ try {
+ Group.Synchronized (null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("inner", ex.ParamName, "#6");
+ }
}
[Test]
{
Group eg = Match.Empty.Groups[0];
Group sg = Match.Synchronized (eg);
- Assert.IsTrue (Object.ReferenceEquals (eg, sg), "Synchronized");
+ Assert.AreSame (eg, sg, "Synchronized");
}
}
}
public class MatchTest
{
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void Synchronized_Null ()
+ public void Synchronized_Inner_Null ()
{
- Match.Synchronized (null);
+ try {
+ Match.Synchronized (null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("inner", ex.ParamName, "#6");
+ }
}
[Test]
{
Match em = Match.Empty;
Match sm = Match.Synchronized (em);
- Assert.IsTrue (Object.ReferenceEquals (em, sm), "Synchronized");
+ Assert.AreSame (em, sm, "Synchronized");
}
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
- public void Result_Null ()
+ public void Result_Replacement_Null ()
{
- Match.Empty.Result (null);
+ try {
+ Match.Empty.Result (null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("replacement", ex.ParamName, "#6");
+ }
}
[Test]
- [ExpectedException (typeof (NotSupportedException))]
- public void Result_Empty ()
+ public void Result_Replacement_Empty ()
{
- Match.Empty.Result (String.Empty);
+ Regex email = new Regex ("(?<user>[^@]+)@(?<domain>.+)");
+ Match m = email.Match ("mono@go-mono.com");
+ string exp = m.Result (string.Empty);
+ Assert.AreEqual (string.Empty, exp);
+ }
+
+ [Test]
+ public void Result_Match_Empty ()
+ {
+ try {
+ Match.Empty.Result ("whatever");
+ Assert.Fail ("#1");
+ } catch (NotSupportedException ex) {
+ // Result cannot be called on failed Match
+ Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ }
}
}
}
+ " Group[10]=(9,2)"
+ " Group[11]=(11,1)"
),
- new RegexTrial (@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", RegexOptions.ExplicitCapture, "F2345678910LL", "Fail"),//5
+ new RegexTrial (@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", RegexOptions.ExplicitCapture, "F2345678910LL", "Fail."),//5
new RegexTrial (@"(F)(2)(3)(4)(5)(6)(?<S>7)(8)(9)(10)(L)\1", RegexOptions.None, "F2345678910L71", "Fail."),//6
new RegexTrial (@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", RegexOptions.None, "F2345678910LF1", "Fail."),//7
new RegexTrial (@"(F)(2)(3)(4)(5)(6)(?<S>7)(8)(9)(10)(L)\11", RegexOptions.None, "F2345678910L71", "Pass."//8
new RegexTrial (@"(?>a*).", RegexOptions.ExplicitCapture, "aaaa", "Fail."),//52
};
- [Test] public void RegexJvmTrial0000 () { trials [0].Execute (); }
- [Test] public void RegexJvmTrial0001 () { trials [1].Execute (); }
+ [Test]
+ public void RegexJvmTrial0000 ()
+ {
+ trials [0].Execute ();
+ }
+
+ [Test]
+ public void RegexJvmTrial0001 ()
+ {
+ trials [1].Execute ();
+ }
[Test]
+ [Category ("NotDotNet")]
[Category ("NotWorking")]
- public void RegexJvmTrial0002 () { trials [2].Execute (); }
+ public void RegexJvmTrial0002 ()
+ {
+ trials [2].Execute ();
+ }
+
+ [Test]
+ public void RegexJvmTrial0003 ()
+ {
+ trials [3].Execute ();
+ }
- [Test] public void RegexJvmTrial0003 () { trials [3].Execute (); }
- [Test] public void RegexJvmTrial0004 () { trials [4].Execute (); }
+ [Test]
+ public void RegexJvmTrial0004 ()
+ {
+ trials [4].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0005 () { trials [5].Execute (); }
+ public void RegexJvmTrial0005 ()
+ {
+ trials [5].Execute ();
+ }
- [Test] public void RegexJvmTrial0006 () { trials [6].Execute (); }
- [Test] public void RegexJvmTrial0007 () { trials [7].Execute (); }
+ [Test]
+ public void RegexJvmTrial0006 ()
+ {
+ trials [6].Execute ();
+ }
+
+ [Test]
+ public void RegexJvmTrial0007 ()
+ {
+ trials [7].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0008 () { trials [8].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0008 ()
+ {
+ trials [8].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0009 () { trials [9].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0009 ()
+ {
+ trials [9].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0010 () { trials [10].Execute (); }
+ public void RegexJvmTrial0010 ()
+ {
+ trials [10].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0011 () { trials [11].Execute (); }
+ public void RegexJvmTrial0011 ()
+ {
+ trials [11].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0012 () { trials [12].Execute (); }
+ public void RegexJvmTrial0012 ()
+ {
+ trials [12].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0013 () { trials [13].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0013 ()
+ {
+ trials [13].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0014 () { trials [14].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0014 ()
+ {
+ trials [14].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0015 () { trials [15].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0015 ()
+ {
+ trials [15].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0016 () { trials [16].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0016 ()
+ {
+ trials [16].Execute ();
+ }
- [Test] public void RegexJvmTrial0017 () { trials [17].Execute (); }
+ [Test]
+ public void RegexJvmTrial0017 ()
+ {
+ trials [17].Execute ();
+ }
[Test]
[Category ("NotWorking")]
- public void RegexJvmTrial0018 () { trials [18].Execute (); }
+ [Category ("NotDotNet")]
+ public void RegexJvmTrial0018 ()
+ {
+ trials [18].Execute ();
+ }
[Test] public void RegexJvmTrial0019 () { trials [19].Execute (); }
[Test] public void RegexJvmTrial0020 () { trials [20].Execute (); }
catch (Exception e) {
result = "Error.";
}
- Assert.AreEqual (result, expected, "rr#: {1} ~ s,{2},{3},",
- original, pattern, replacement);
+ Assert.AreEqual (expected, result, "rr#: {0} ~ s,{1},{2},",
+ original, pattern, replacement);
}
}