public void TestCharacterRangeNodeRendering() { RegexNodeCharacterRange characterRange1 = new RegexNodeCharacterRange('b', 'x', false); Assert.AreEqual(@"[b-x]", characterRange1.ToRegexPattern()); characterRange1.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[b-x]*", characterRange1.ToRegexPattern()); characterRange1.Quantifier = RegexQuantifier.None; characterRange1.UseCharacterCodes = true; Assert.AreEqual(@"[\u0062-\u0078]", characterRange1.ToRegexPattern()); characterRange1.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[\u0062-\u0078]*", characterRange1.ToRegexPattern()); RegexNodeCharacterRange characterRange2 = new RegexNodeCharacterRange('b', 'x', true); Assert.AreEqual(@"[^b-x]", characterRange2.ToRegexPattern()); characterRange2.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^b-x]*", characterRange2.ToRegexPattern()); characterRange2.Quantifier = RegexQuantifier.None; characterRange2.UseCharacterCodes = true; Assert.AreEqual(@"[^\u0062-\u0078]", characterRange2.ToRegexPattern()); characterRange2.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^\u0062-\u0078]*", characterRange2.ToRegexPattern()); RegexNodeCharacterRange characterRange3 = RegexBuilder.CharacterRange('b', 'x', false, RegexQuantifier.None); Assert.AreEqual(@"[b-x]", characterRange3.ToRegexPattern()); characterRange3.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[b-x]*", characterRange3.ToRegexPattern()); characterRange3.Quantifier = RegexQuantifier.None; characterRange3.UseCharacterCodes = true; Assert.AreEqual(@"[\u0062-\u0078]", characterRange3.ToRegexPattern()); characterRange3.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[\u0062-\u0078]*", characterRange3.ToRegexPattern()); RegexNodeCharacterRange characterRange4 = RegexBuilder.NegativeCharacterRange('b', 'x', false, RegexQuantifier.None); Assert.AreEqual(@"[^b-x]", characterRange4.ToRegexPattern()); characterRange4.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^b-x]*", characterRange4.ToRegexPattern()); characterRange4.Quantifier = RegexQuantifier.None; characterRange4.UseCharacterCodes = true; Assert.AreEqual(@"[^\u0062-\u0078]", characterRange4.ToRegexPattern()); characterRange4.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^\u0062-\u0078]*", characterRange4.ToRegexPattern()); }
public void TestCharacterRangeNodeRendering() { RegexNodeCharacterRange characterRange1 = new RegexNodeCharacterRange('b', 'x', false); Assert.AreEqual(@"[b-x]", characterRange1.ToRegexPattern()); characterRange1.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[b-x]*", characterRange1.ToRegexPattern()); characterRange1.Quantifier = RegexQuantifier.None; characterRange1.UseCharacterCodes = true; Assert.AreEqual(@"[\u0062-\u0078]", characterRange1.ToRegexPattern()); characterRange1.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[\u0062-\u0078]*", characterRange1.ToRegexPattern()); RegexNodeCharacterRange characterRange2 = new RegexNodeCharacterRange('b', 'x', true); Assert.AreEqual(@"[^b-x]", characterRange2.ToRegexPattern()); characterRange2.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^b-x]*", characterRange2.ToRegexPattern()); characterRange2.Quantifier = RegexQuantifier.None; characterRange2.UseCharacterCodes = true; Assert.AreEqual(@"[^\u0062-\u0078]", characterRange2.ToRegexPattern()); characterRange2.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^\u0062-\u0078]*", characterRange2.ToRegexPattern()); RegexNodeCharacterRange characterRange3 = RegexBuilder.CharacterRange('b', 'x', false, RegexQuantifier.None); Assert.AreEqual(@"[b-x]", characterRange3.ToRegexPattern()); characterRange3.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[b-x]*", characterRange3.ToRegexPattern()); characterRange3.Quantifier = RegexQuantifier.None; characterRange3.UseCharacterCodes = true; Assert.AreEqual(@"[\u0062-\u0078]", characterRange3.ToRegexPattern()); characterRange3.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[\u0062-\u0078]*", characterRange3.ToRegexPattern()); RegexNodeCharacterRange characterRange4 = RegexBuilder.NegativeCharacterRange('b', 'x', false, RegexQuantifier.None); Assert.AreEqual(@"[^b-x]", characterRange4.ToRegexPattern()); characterRange4.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^b-x]*", characterRange4.ToRegexPattern()); characterRange4.Quantifier = RegexQuantifier.None; characterRange4.UseCharacterCodes = true; Assert.AreEqual(@"[^\u0062-\u0078]", characterRange4.ToRegexPattern()); characterRange4.Quantifier = RegexQuantifier.ZeroOrMore; Assert.AreEqual(@"[^\u0062-\u0078]*", characterRange4.ToRegexPattern()); }