* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System / Test / System.Text.RegularExpressions / RegexBugs.cs
index 536a9580626c4597183990070c7f2fb637b932a5..dc68c6693275fc4d64c68ca99eb6d26477c776dc 100644 (file)
@@ -9,6 +9,7 @@
 
 using NUnit.Framework;
 using System;
+using System.Text;
 using System.Text.RegularExpressions;
 
 namespace MonoTests.System.Text.RegularExpressions
@@ -353,5 +354,70 @@ namespace MonoTests.System.Text.RegularExpressions
                        m = new Regex("'.*?[^,]'").Match(s1); Assert ("#03", m.Success); AssertEquals ("#03v", s1, m.Value);
                        m = new Regex("'.*?[^,]'").Match(s2); Assert ("#04", m.Success); AssertEquals ("#04v", s2, m.Value);
                }
+
+               [Test]
+               public void Bug78007 ()
+               {
+                       string test = "head&gt;<html>";
+                       string pattern = @"\Ahead&gt;\<html\>";
+                       Regex r = new Regex (pattern);
+                       Match m = r.Match (test);
+                       Assert ("#01", m.Success);
+                       AssertEquals ("#01i", 0, m.Index);
+                       AssertEquals ("#01l", 14, m.Length);
+
+                       m = m.NextMatch ();
+                       Assert ("#02", !m.Success);
+               }
+
+               [Test]
+               public void CharClassWithIgnoreCase ()
+               {
+                       string str = "Foobar qux";
+                       Regex re = new Regex (@"[a-z\s]*", RegexOptions.IgnoreCase);
+                       Match m = re.Match (str);
+                       AssertEquals ("#01", str, m.Value);
+                }
+
+               void Kill65535_1 (int length)
+               {
+                       StringBuilder sb = new StringBuilder ("x");
+                       sb.Append ('a', length);
+                       sb.Append ('y');
+                       string teststring = sb.ToString ();
+                       Regex regex = new Regex (@"xa*y");
+                       Match m = regex.Match (teststring);
+                       Assert ("#01 " + length, m.Success);
+                       AssertEquals ("#02 " + length, m.Index, 0);
+                       AssertEquals ("#03 " + length, m.Length, teststring.Length);
+               }
+
+               void Kill65535_2 (int length)
+               {
+                       StringBuilder sb = new StringBuilder ("xaaaax");
+                       sb.Append ('a', length);
+                       sb.Append ('y');
+                       string teststring = sb.ToString ();
+                       Regex regex = new Regex (@"x.*y");
+                       Match m = regex.Match(teststring);
+                       Assert ("#01 " + length, m.Success);
+                       AssertEquals ("#02 " + length, m.Index, 0);
+                       AssertEquals ("#03 " + length, m.Length, teststring.Length);
+               }
+               
+
+               [Test] // Based on bug #78278
+               public void No65535Limit ()
+               {
+                       Kill65535_1 (65535);
+                       Kill65535_1 (65536);
+                       Kill65535_1 (131071);
+                       Kill65535_1 (131072);
+
+                       Kill65535_2 (65530);
+                       Kill65535_2 (65531);
+                       Kill65535_2 (131066);
+                       Kill65535_2 (131067);
+               } 
        }
 }