예제 #1
0
        public void TakeArgumentStateLogInitTest()
        {
            var sut       = new RemoveArgumentStateLog();
            var initHisto = sut.ToString(true);

            const string expected = @"
                                             Start:    0
                                 LeadingWhitespace:    0
                  ScanningBackslashesOutsideQuotes:    0
                QuoteAfterBackslashesOutsideQuotes:    0
                  EmittingBackslashesOutsideQuotes:    0
                  CheckForArgumentEndOutsideQuotes:    0
 EmittingBackslashesOutsideQuotesGoingInsideQuotes:    0
                   ScanningBackslashesInsideQuotes:    0
                 QuoteAfterBackslashesInsideQuotes:    0
                   EmittingBackslashesInsideQuotes:    0
     CheckForTwoQuotesAfterBackslashesInsideQuotes:    0
 EmittingBackslashesInsideQuotesGoingOutsideQuotes:    0
 CheckForArgumentEndInsideQuotesGoingOutsideQuotes:    0
EmittingBackslashesInsideQuotesStayingInsideQuotes:    0
                  EmitFinalBackslashesInsideQuotes:    0
                                         CopyToEnd:    0
                                               End:    0
";

            Assert.Equal(expected, initHisto);
        }
예제 #2
0
        public void TakeArgumentStateLogWithLoggingTest()
        {
            var sut = new RemoveArgumentStateLog();
            var sb  = new StringBuilder();

            sb.Append('x');
            sut.Add("Start-a-0-x", CppArgumentLexing.ArgStates.Start, 'a', 0, sb);
            sb.Append('y');
            sut.Add("LeadingWhitespace-b-1-xy", CppArgumentLexing.ArgStates.LeadingWhitespace, 'b', 1, sb);
            sb.Append('z');
            sut.Add("EmitFinalBackslashesInsideQuotes-c-2-xyz", CppArgumentLexing.ArgStates.EmitFinalBackslashesInsideQuotes, 'c', 2, sb);
            sb.Append('w');
            sut.Add("LeadingWhitespace-d-3-xyzw", CppArgumentLexing.ArgStates.LeadingWhitespace, 'd', 3, sb);
            var log = sut.ToString();

            output_.WriteLine(log);
            const string expectedLog = @"(Start-a-0-x, Start, 'a', 0, ""x"")
(LeadingWhitespace-b-1-xy, LeadingWhitespace, 'b', 1, ""xy"")
(EmitFinalBackslashesInsideQuotes-c-2-xyz, EmitFinalBackslashesInsideQuotes, 'c', 2, ""xyz"")
(LeadingWhitespace-d-3-xyzw, LeadingWhitespace, 'd', 3, ""xyzw"")
";

            Assert.Equal(expectedLog, log);

            var          histo         = sut.ToString(true);
            const string expectedHisto = expectedLog + @"
                                             Start:    1
                                 LeadingWhitespace:    2
                  ScanningBackslashesOutsideQuotes:    0
                QuoteAfterBackslashesOutsideQuotes:    0
                  EmittingBackslashesOutsideQuotes:    0
                  CheckForArgumentEndOutsideQuotes:    0
 EmittingBackslashesOutsideQuotesGoingInsideQuotes:    0
                   ScanningBackslashesInsideQuotes:    0
                 QuoteAfterBackslashesInsideQuotes:    0
                   EmittingBackslashesInsideQuotes:    0
     CheckForTwoQuotesAfterBackslashesInsideQuotes:    0
 EmittingBackslashesInsideQuotesGoingOutsideQuotes:    0
 CheckForArgumentEndInsideQuotesGoingOutsideQuotes:    0
EmittingBackslashesInsideQuotesStayingInsideQuotes:    0
                  EmitFinalBackslashesInsideQuotes:    1
                                         CopyToEnd:    0
                                               End:    0
";

            Assert.Equal(expectedHisto, histo);
        }
예제 #3
0
        public void TakeArgumentTests(string input, string expectedArgument, string expectedRemainingLine)
        {
            var argumentStream = input.ToCharArray().AsEnumerable();
            var argumentValue  = new StringBuilder();
            var log            = new RemoveArgumentStateLog();
            var remainingLine  = input.RemoveArgument(argumentValue, log).Collect();

            output_.WriteLine(log.ToString(true));
            argumentValue.ToString().Should().Be(expectedArgument, "arg failed, input was \"{0}\"", input.ToLiteralFormat());
            remainingLine.Should().Be(expectedRemainingLine, "remaining failed, input was \"{0}\"", input.ToLiteralFormat());
        }