コード例 #1
0
ファイル: InComment.cs プロジェクト: psryland/rylogic_code
        public void NoCommentsWithinLiteralStrings()
        {
            // No comments within literal strings
            string src = " \"// /* */\" ";

            int[] exp = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
コード例 #2
0
ファイル: InComment.cs プロジェクト: psryland/rylogic_code
        public void IgnoreLiteralStringsWithinComments()
        {
            // Ignore literal strings within comments
            string src = " /* \" */ // \" \n ";

            int[] exp = { 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
コード例 #3
0
ファイル: InComment.cs プロジェクト: psryland/rylogic_code
        public void LineCommentEndsAsEoS()
        {
            // Line comment ends at EOS
            string src = " // ";

            int[] exp = { 0, 1, 1, 1, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
コード例 #4
0
ファイル: InComment.cs プロジェクト: psryland/rylogic_code
        public void LineCommentEndsAtUnescapedNewLine()
        {
            // Line comment ends at unescaped new line (exclusive)
            string src = " // \\\n \n ";

            int[] exp = { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
コード例 #5
0
ファイル: InComment.cs プロジェクト: psryland/rylogic_code
        public void NoSubstringMatchingWithinBlockCommentMarkers()
        {
            // No substring matching within block comment markers
            string src = "/*/*/ /**/*/";

            int[] exp = { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
コード例 #6
0
ファイル: InComment.cs プロジェクト: psryland/rylogic_code
        public void SimpleBlockComment()
        {
            // Simple block comment
            string src = " /**/ ";

            int[] exp = { 0, 1, 1, 1, 1, 0 };

            var com = new InComment();

            for (int i = 0; i != src.Length; ++i)
            {
                Assert.Equal(exp[i], com.WithinComment(src, i) ? 1 : 0);
            }
        }
コード例 #7
0
 public StripComments(Src src, InLiteral.EFlags literal_flags = InLiteral.EFlags.Escaped | InLiteral.EFlags.SingleLineStrings, InComment.Patterns?comment_patterns = null)
     : base(src)
 {
     m_com = new InComment(comment_patterns ?? new InComment.Patterns(), literal_flags);
 }