public void TestConditionalMatchNodeRendering() { RegexNodeLiteral condition = new RegexNodeLiteral(@"\w\s"); RegexNodeLiteral trueMatch = new RegexNodeLiteral(@"\w\s\d{5}-[^\u005c]+"); RegexNodeLiteral falseMatch = new RegexNodeLiteral(@"\d{5,}\u005d"); RegexNodeConditionalMatch conditionalMatch1 = new RegexNodeConditionalMatch(condition, trueMatch, falseMatch); Assert.AreEqual(@"(?(\w\s)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)", conditionalMatch1.ToRegexPattern()); conditionalMatch1.Quantifier = RegexQuantifier.OneOrMore; Assert.AreEqual(@"(?(\w\s)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)+", conditionalMatch1.ToRegexPattern()); RegexNodeConditionalMatch conditionalMatch2 = new RegexNodeConditionalMatch("SomeGroup", trueMatch, falseMatch); Assert.AreEqual(@"(?(SomeGroup)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)", conditionalMatch2.ToRegexPattern()); conditionalMatch2.Quantifier = RegexQuantifier.OneOrMore; Assert.AreEqual(@"(?(SomeGroup)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)+", conditionalMatch2.ToRegexPattern()); RegexNodeConditionalMatch conditionalMatch3 = RegexBuilder.ConditionalMatch(condition, trueMatch, falseMatch); Assert.AreEqual(@"(?(\w\s)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)", conditionalMatch3.ToRegexPattern()); conditionalMatch3 = RegexBuilder.ConditionalMatch(condition, trueMatch, falseMatch, RegexQuantifier.OneOrMore); Assert.AreEqual(@"(?(\w\s)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)+", conditionalMatch3.ToRegexPattern()); RegexNodeConditionalMatch conditionalMatch4 = RegexBuilder.ConditionalMatch("SomeGroup", trueMatch, falseMatch); Assert.AreEqual(@"(?(SomeGroup)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)", conditionalMatch4.ToRegexPattern()); conditionalMatch4 = RegexBuilder.ConditionalMatch("SomeGroup", trueMatch, falseMatch, RegexQuantifier.OneOrMore); Assert.AreEqual(@"(?(SomeGroup)\w\s\d{5}-[^\u005c]+|\d{5,}\u005d)+", conditionalMatch4.ToRegexPattern()); }
public void TestConditionalMatchNodeNullAssignment2() { RegexNodeLiteral condition = new RegexNodeLiteral("a"); RegexNodeLiteral falseMatch = new RegexNodeLiteral("c"); RegexNodeConditionalMatch conditionalMatch = new RegexNodeConditionalMatch(condition, null, falseMatch); Assert.IsNull(conditionalMatch); }
public void TestConditionalMatchNodeNullAssignment1() { RegexNodeLiteral condition = new RegexNodeLiteral("a"); RegexNodeLiteral trueMatch = new RegexNodeLiteral("b"); RegexNodeConditionalMatch conditionalMatch = new RegexNodeConditionalMatch(condition, trueMatch, null); Assert.IsNull(conditionalMatch); }
public void TestConditionalMatchNodeNullAssignment3() { RegexNodeLiteral condition = new RegexNodeLiteral("a"); RegexNodeLiteral trueMatch = new RegexNodeLiteral("b"); RegexNodeLiteral falseMatch = new RegexNodeLiteral("c"); RegexNodeConditionalMatch conditionalMatch = new RegexNodeConditionalMatch(condition, trueMatch, falseMatch); conditionalMatch.TrueMatchExpression = null; conditionalMatch.FalseMatchExpression = null; Assert.IsNull(conditionalMatch); }