Exemple #1
0
        public void IsPositionInComment()
        {
            //                012345678901234567890123456789
            string source   = @" /* 1 */ /* 2 */ /* 3 */ ";
            var    comments = new CommentParser().Parse(source);

            Assert.AreEqual(3, comments.Count);
            Assert.IsFalse(comments.IsPositionInComment(0));
            Assert.IsFalse(comments.IsPositionInComment(8));
            Assert.IsFalse(comments.IsPositionInComment(16));
            Assert.IsFalse(comments.IsPositionInComment(24));

            Assert.IsTrue(comments.IsPositionInComment(9));
            Assert.IsTrue(comments.IsPositionInComment(10));
            Assert.IsTrue(comments.IsPositionInComment(11));
            Assert.IsTrue(comments.IsPositionInComment(12));
            Assert.IsTrue(comments.IsPositionInComment(13));
            Assert.IsTrue(comments.IsPositionInComment(14));
            Assert.IsTrue(comments.IsPositionInComment(15));

            Assert.IsTrue(comments.IsPositionInComment(1));
            Assert.IsTrue(comments.IsPositionInComment(2));
            Assert.IsTrue(comments.IsPositionInComment(3));
            Assert.IsTrue(comments.IsPositionInComment(4));
            Assert.IsTrue(comments.IsPositionInComment(5));
            Assert.IsTrue(comments.IsPositionInComment(6));
            Assert.IsTrue(comments.IsPositionInComment(7));
        }
        public void IsPositionInComment()
        {
            //                012345678901234567890123456789
            string source = @" /* 1 */ /* 2 */ /* 3 */ ";
            var comments = new CommentParser().Parse(source);
            Assert.AreEqual(3, comments.Count);
            Assert.IsFalse(comments.IsPositionInComment(0));
            Assert.IsFalse(comments.IsPositionInComment(8));
            Assert.IsFalse(comments.IsPositionInComment(16));
            Assert.IsFalse(comments.IsPositionInComment(24));

            Assert.IsTrue(comments.IsPositionInComment(9));
            Assert.IsTrue(comments.IsPositionInComment(10));
            Assert.IsTrue(comments.IsPositionInComment(11));
            Assert.IsTrue(comments.IsPositionInComment(12));
            Assert.IsTrue(comments.IsPositionInComment(13));
            Assert.IsTrue(comments.IsPositionInComment(14));
            Assert.IsTrue(comments.IsPositionInComment(15));

            Assert.IsTrue(comments.IsPositionInComment(1));
            Assert.IsTrue(comments.IsPositionInComment(2));
            Assert.IsTrue(comments.IsPositionInComment(3));
            Assert.IsTrue(comments.IsPositionInComment(4));
            Assert.IsTrue(comments.IsPositionInComment(5));
            Assert.IsTrue(comments.IsPositionInComment(6));
            Assert.IsTrue(comments.IsPositionInComment(7));
        }