Exemple #1
0
        public void IsCommentTest_BlockComment()
        {
            var pattern = new CodeCommentPattern("/*", "*/");

            Assert.IsTrue(pattern.IsComment("/**/"));
            Assert.IsTrue(pattern.IsComment(" /**/"));
            Assert.IsTrue(pattern.IsComment("/**/ "));
            Assert.IsTrue(pattern.IsComment("/*hoge*/"));
            Assert.IsTrue(pattern.IsComment(string.Join(Environment.NewLine, "/*", "hoge", "*/")));

            Assert.IsFalse(pattern.IsComment("/*"));
            Assert.IsFalse(pattern.IsComment("*/"));

            Assert.IsFalse(pattern.IsComment("/ /"));
            Assert.IsFalse(pattern.IsComment("/ *"));
            Assert.IsFalse(pattern.IsComment("* /"));
            Assert.IsFalse(pattern.IsComment("* *"));

            Assert.IsFalse(pattern.IsComment("* */"));
            Assert.IsFalse(pattern.IsComment("/* *"));

            Assert.IsFalse(pattern.IsComment(string.Empty));
            Assert.IsFalse(pattern.IsComment(" "));
            Assert.IsFalse(pattern.IsComment(Environment.NewLine));
        }
Exemple #2
0
        public void IsCommentTest_LineComment()
        {
            var pattern = new CodeCommentPattern("//");

            Assert.IsTrue(pattern.IsComment("//"));
            Assert.IsTrue(pattern.IsComment("///"));
            Assert.IsTrue(pattern.IsComment(" //"));
            Assert.IsTrue(pattern.IsComment("\t//"));
            Assert.IsTrue(pattern.IsComment("\t //"));

            Assert.IsFalse(pattern.IsComment("/"));
            Assert.IsFalse(pattern.IsComment("hoge//"));

            Assert.IsTrue(pattern.IsComment(string.Join(Environment.NewLine, "//", "//")));
            Assert.IsTrue(pattern.IsComment(string.Join(Environment.NewLine, "//", string.Empty, "//")));
            Assert.IsFalse(pattern.IsComment(string.Join(Environment.NewLine, "//", "hoge", "//")));

            Assert.IsFalse(pattern.IsComment(string.Empty));
            Assert.IsFalse(pattern.IsComment(" "));
            Assert.IsFalse(pattern.IsComment(Environment.NewLine));
        }