Пример #1
0
        public void IsCommentSymbolTest()
        {
            СCommentSymbols target = BaseTest();

            string[] pair_comment_symbols     = { "/*", "*/" };
            string[] not_pair_comment_symbols = { "//", "///" };
            string[] non_comment_symbols      = { "\\\\", "////", "rttt" };
            bool     IsNotPair = false;

            foreach (string symbol in pair_comment_symbols)
            {
                Assert.IsTrue(target.IsCommentSymbol(symbol, ref IsNotPair));
                Assert.IsFalse(IsNotPair);
            }

            foreach (string symbol in not_pair_comment_symbols)
            {
                Assert.IsTrue(target.IsCommentSymbol(symbol, ref IsNotPair));
                Assert.IsTrue(IsNotPair);
            }

            foreach (string symbol in non_comment_symbols)
            {
                Assert.IsFalse(target.IsCommentSymbol(symbol, ref IsNotPair));
                Assert.IsTrue(IsNotPair);
            }
        }
Пример #2
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private СCommentSymbols BaseTest()
        {
            СCommentSymbols target = new СCommentSymbols(comments);

            Assert.IsNotNull(target);

            return(target);
        }
        public void CommentSymbolsTest()
        {
            CCodePreProcessingOptions target   = BaseTest();
            СCommentSymbols           expected = new СCommentSymbols(comments);
            СCommentSymbols           actual   = target.CommentSymbols;

            Assert.AreEqual(actual, expected);
        }
Пример #4
0
        public void SetCommentSymbolsTest()
        {
            СCommentSymbols target = new СCommentSymbols();

            Assert.IsNotNull(target);
            target.SetCommentSymbols(comments);
            Assert.AreEqual(target.MinCommentLength, 2);
            Assert.AreEqual(target.MaxCommentLength, 3);

            target.SetCommentSymbols(string.Empty);
        }
Пример #5
0
        public void ToArrayTest()
        {
            СCommentSymbols target = BaseTest();

            string[] expected = { "//", string.Empty, "/*", "*/", "///", string.Empty };
            string[] actual   = target.ToArray();
            Assert.AreEqual(expected.Length, actual.Length);
            for (int counter = 0; counter < actual.Length; counter++)
            {
                Assert.AreEqual(expected[counter], actual[counter]);
            }
        }
Пример #6
0
        public void IsCommentCharTest()
        {
            СCommentSymbols target = BaseTest();

            char[] comment_items = { '*', '/' };
            foreach (char item in comment_items)
            {
                Assert.IsTrue(target.IsCommentChar(item));
            }

            char[] non_comment_items = { '\r', '\\', '&' };
            foreach (char item in non_comment_items)
            {
                Assert.IsFalse(target.IsCommentChar(item));
            }
        }
Пример #7
0
        private void CommentListTest()
        {
            СCommentSymbols actual = new СCommentSymbols();

            Assert.IsNotNull(actual);
            actual.AddCommentInList(new CPair <string>("//", string.Empty));
            actual.AddCommentInList(new CPair <string>("/*", "*/"));
            actual.AddCommentInList(new CPair <string>("///", string.Empty));

            СCommentSymbols expected = BaseTest();

            Assert.IsNotNull(expected);
            Assert.AreEqual(expected.GetCommentSymbolsList().Count, 3);
            Assert.AreEqual(expected.GetCommentSymbolsList().Count, actual.GetCommentSymbolsList().Count);

            for (int counter = 0; counter < expected.GetCommentSymbolsList().Count; counter++)
            {
                Assert.AreEqual(expected.GetCommentSymbolsList()[counter], actual.GetCommentSymbolsList()[counter]);
            }
        }
Пример #8
0
        public void MinCommentLengthTest()
        {
            СCommentSymbols target = BaseTest();

            Assert.AreEqual(target.MinCommentLength, 2);
        }
Пример #9
0
        public void СCommentSymbolsConstructorTest()
        {
            СCommentSymbols target = BaseTest();

            target = new СCommentSymbols(string.Empty);
        }