예제 #1
0
        public void AllCharsTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = ".";

            target.CharClass();

            Graph verificationGraph = new Graph();

            BaseVertex start = verificationGraph.StartVertex;
            start.Accepting = false;
            StringBuilder allChar = new StringBuilder();
            for (int i = 32; i <= 126; i++)
            {
                allChar.Append((char)i);
            }
            string trans = allChar.ToString();
            BaseVertex end = verificationGraph.CreateNewVertex(true);
            start.AddConnection(end, trans);

            Graph generated = target.lineGraph;

            Assert.AreEqual<Graph>(verificationGraph, generated, "Graphs are not equal.  \nExpected:\n\n{0}\n\nReceived:\n\n{1}",
                verificationGraph.ToDOT("Expected"), generated.ToDOT("Generated"));
            Assert.AreEqual<int>(target.tokenBuffer.Length, target.tokenPosition, "Token position is not in correct location. Expected {0}, Actual {1}",
                1, target.tokenPosition);
        }
예제 #2
0
        public void BadBracketEndTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = "[]]";

            target.CharClass();
        }
예제 #3
0
        public void UnescapedSlashTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = @"[\]";

            target.CharClass();
        }
예제 #4
0
        public void SimpleBracketZeroTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = "[0]";

            target.CharClass();

            Graph verificationGraph = new Graph();

            BaseVertex start = verificationGraph.StartVertex;
            start.Accepting = false;

            BaseVertex newV = verificationGraph.CreateNewVertex(true);
            start.AddConnection(newV, "0");

            Graph generated = target.lineGraph;

            Assert.AreEqual<Graph>(verificationGraph, generated, "Graphs are not equal.  \nExpected:\n\n{0}\n\nReceived:\n\n{1}",
                verificationGraph.ToDOT("Expected"), generated.ToDOT("Generated"));
            Assert.AreEqual<int>(target.tokenBuffer.Length, target.tokenPosition, "Token position is not in correct location. Expected {0}, Actual {1}",
                1, target.tokenPosition);
        }
예제 #5
0
        public void NoDefinedCharClassExceptTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = @"[^b] IN $LOLNO";

            target.CharClass();
        }
예제 #6
0
        public void FullAlphaNumRangeTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = "[a-zA-Z0-9]";

            target.CharClass();

            Graph verificationGraph = new Graph();

            BaseVertex start = verificationGraph.StartVertex;
            start.Accepting = false;

            BaseVertex newV = verificationGraph.CreateNewVertex(true);
            start.AddConnection(newV, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

            Graph generated = target.lineGraph;

            Assert.AreEqual<Graph>(verificationGraph, generated, "Graphs are not equal.  \nExpected:\n\n{0}\n\nReceived:\n\n{1}",
                verificationGraph.ToDOT("Expected"), generated.ToDOT("Generated"));
            Assert.AreEqual<int>(target.tokenBuffer.Length, target.tokenPosition, "Token position is not in correct location. Expected {0}, Actual {1}",
                1, target.tokenPosition);
        }
예제 #7
0
        public void FinalEmptySetTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = @"[^b] IN [b]";

            target.CharClass();
        }
예제 #8
0
        public void DefinedCharClassExclusionTest()
        {
            RDMain inst = this.testInst;
            PrivateObject param0 = new PrivateObject(inst); // TODO: Initialize to an appropriate value
            RDMain_Accessor target = new RDMain_Accessor(param0); // TODO: Initialize to an appropriate value
            target.tokenBuffer = "[^0] IN $DIGIT";
            target.characterClasses["DIGIT"] = new Graph();
            BaseVertex v = target.characterClasses["DIGIT"].CreateNewVertex(true);
            target.characterClasses["DIGIT"].StartVertex.Accepting = false;
            target.characterClasses["DIGIT"].StartVertex.AddConnection(v, "0123456789");

            target.Regexp();

            Graph verificationGraph = new Graph();

            BaseVertex start = verificationGraph.StartVertex;
            start.Accepting = false;
            BaseVertex end = verificationGraph.CreateNewVertex(true);
            start.AddConnection(end, "123456789");

            Graph generated = target.lineGraph;

            Assert.AreEqual<Graph>(verificationGraph, generated, "Graphs are not equal.  \nExpected:\n\n{0}\n\nReceived:\n\n{1}",
                verificationGraph.ToDOT("Expected"), generated.ToDOT("Generated"));
            Assert.AreEqual<int>(target.tokenBuffer.Length, target.tokenPosition, "Token position is not in correct location. Expected {0}, Actual {1}",
                1, target.tokenPosition);
        }