public void TryParseGroupTest1() { int pos = 0; IList <string> words; Assert.IsFalse(RegexParser.TryParseGroup(null, ref pos, out words)); Assert.AreEqual(0, pos); Assert.IsFalse(RegexParser.TryParseGroup(string.Empty, ref pos, out words)); Assert.AreEqual(0, pos); Assert.IsFalse(RegexParser.TryParseGroup("A", ref pos, out words)); Assert.AreEqual(0, pos); }
public void TryParseGroupTest0() { int pos = 0; IList <string> words; Assert.IsTrue(RegexParser.TryParseGroup("(A)", ref pos, out words)); Assert.AreEqual(1, words.Count); CollectionAssert.AreEqual(new string[] { "A" }, words.ToArray()); pos = 0; Assert.IsTrue(RegexParser.TryParseGroup("(A|AB|ABC)", ref pos, out words)); Assert.AreEqual(3, words.Count); CollectionAssert.AreEqual(new string[] { "A", "AB", "ABC" }, words.ToArray()); }
public void TryParseGroupTest4() { try { int pos = 0; IList <string> words; Assert.IsFalse(RegexParser.TryParseGroup("()", ref pos, out words)); } catch (ArgumentException e) { Assert.AreEqual( new ArgumentException(string.Format( CultureInfo.InvariantCulture, Properties.Resources.E_InvalidRegex_GroupIsEmpty, "()", 1)).Message, e.Message); throw; } }