Beispiel #1
0
        public void TestGroupNodeNullAssignment2()
        {
            RegexNodeGroup group = new RegexNodeGroup(new RegexNodeLiteral("abc"));

            group.InnerExpression = null;
            Assert.IsNull(group);
        }
        public void TestGroupNodeRendering()
        {
            RegexNodeLiteral literal = new RegexNodeLiteral("abc");

            RegexNodeGroup group1 = new RegexNodeGroup(literal);

            Assert.AreEqual("(abc)", group1.ToRegexPattern());
            group1.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual("(abc)*", group1.ToRegexPattern());

            RegexNodeGroup group2 = new RegexNodeGroup(literal, false);

            Assert.AreEqual("(?:abc)", group2.ToRegexPattern());
            group2.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual("(?:abc)*", group2.ToRegexPattern());

            RegexNodeGroup group3 = new RegexNodeGroup(literal, "SomeGroup");

            Assert.AreEqual("(?<SomeGroup>abc)", group3.ToRegexPattern());
            group3.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual("(?<SomeGroup>abc)*", group3.ToRegexPattern());

            RegexNodeGroup group4 = RegexBuilder.Group(literal);

            Assert.AreEqual("(abc)", group4.ToRegexPattern());
            group4 = RegexBuilder.Group(literal, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual("(abc)*", group4.ToRegexPattern());

            RegexNodeGroup group5 = RegexBuilder.NonCapturingGroup(literal);

            Assert.AreEqual("(?:abc)", group5.ToRegexPattern());
            group5 = RegexBuilder.NonCapturingGroup(literal, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual("(?:abc)*", group5.ToRegexPattern());

            RegexNodeGroup group6 = RegexBuilder.Group("SomeGroup", literal);

            Assert.AreEqual("(?<SomeGroup>abc)", group6.ToRegexPattern());
            group6 = RegexBuilder.Group("SomeGroup", literal, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual("(?<SomeGroup>abc)*", group6.ToRegexPattern());
        }
 public void TestGroupNodeNullAssignment2()
 {
     RegexNodeGroup group = new RegexNodeGroup(new RegexNodeLiteral("abc"));
     group.InnerExpression = null;
     Assert.IsNull(group);
 }
 public void TestGroupNodeNullAssignment1()
 {
     RegexNodeGroup group = new RegexNodeGroup(null);
     Assert.IsNull(group);
 }
Beispiel #5
0
        public void TestGroupNodeNullAssignment1()
        {
            RegexNodeGroup group = new RegexNodeGroup(null);

            Assert.IsNull(group);
        }
        public void TestGroupNodeRendering()
        {
            RegexNodeLiteral literal = new RegexNodeLiteral("abc");

            RegexNodeGroup group1 = new RegexNodeGroup(literal);
            Assert.AreEqual("(abc)", group1.ToRegexPattern());
            group1.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual("(abc)*", group1.ToRegexPattern());

            RegexNodeGroup group2 = new RegexNodeGroup(literal, false);
            Assert.AreEqual("(?:abc)", group2.ToRegexPattern());
            group2.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual("(?:abc)*", group2.ToRegexPattern());

            RegexNodeGroup group3 = new RegexNodeGroup(literal, "SomeGroup");
            Assert.AreEqual("(?<SomeGroup>abc)", group3.ToRegexPattern());
            group3.Quantifier = RegexQuantifier.ZeroOrMore;
            Assert.AreEqual("(?<SomeGroup>abc)*", group3.ToRegexPattern());

            RegexNodeGroup group4 = RegexBuilder.Group(literal);
            Assert.AreEqual("(abc)", group4.ToRegexPattern());
            group4 = RegexBuilder.Group(literal, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual("(abc)*", group4.ToRegexPattern());

            RegexNodeGroup group5 = RegexBuilder.NonCapturingGroup(literal);
            Assert.AreEqual("(?:abc)", group5.ToRegexPattern());
            group5 = RegexBuilder.NonCapturingGroup(literal, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual("(?:abc)*", group5.ToRegexPattern());

            RegexNodeGroup group6 = RegexBuilder.Group("SomeGroup", literal);
            Assert.AreEqual("(?<SomeGroup>abc)", group6.ToRegexPattern());
            group6 = RegexBuilder.Group("SomeGroup", literal, RegexQuantifier.ZeroOrMore);
            Assert.AreEqual("(?<SomeGroup>abc)*", group6.ToRegexPattern());
        }