예제 #1
0
        public void TestCaseSensitivity()
        {
            LanguageRules.Symbols = new List <string>()
            {
                "abc"
            };

            CodeColorizer colorizer = GetColorizer(LanguageRules);

            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" INT i ", colorizer.Transform(" INT i "));
            Assert.AreEqual(" ABC def ", colorizer.Transform(" ABC def "));

            LanguageRules.CaseSensitive = false;
            LanguageRules.Symbols       = new List <string>()
            {
                "abc"
            };
            colorizer = GetColorizer(LanguageRules);
            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" keyword i ", colorizer.Transform(" INT i "));
            Assert.AreEqual(" symbol def ", colorizer.Transform(" ABC def "));

            LanguageRules.Symbols       = null;
            LanguageRules.CaseSensitive = true;
        }
예제 #2
0
        public void TestStrings()
        {
            CodeColorizer colorizer = GetColorizer(LanguageRules);

            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" string ", colorizer.Transform(" \"abc\" "));
            Assert.AreEqual(" string ", colorizer.Transform(" 'a' "));
        }
예제 #3
0
        public void TestComments()
        {
            CodeColorizer colorizer = GetColorizer(LanguageRules);

            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" comment", colorizer.Transform(" // Comment "));
            Assert.AreEqual(" comment ", colorizer.Transform(" /* Comment */ "));
        }
예제 #4
0
        public void TestOperators()
        {
            CodeColorizer colorizer = GetColorizer(LanguageRules);

            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" a operator b operator c ", colorizer.Transform(" a = b * c "));
        }
예제 #5
0
        public void TestKeywords()
        {
            CodeColorizer colorizer = GetColorizer(LanguageRules);

            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" keyword i ", colorizer.Transform(" int i "));
        }
예제 #6
0
        public void TestSymbols()
        {
            CodeColorizer colorizer = GetColorizer(LanguageRules);

            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" abc def ", colorizer.Transform(" abc def "));
            colorizer.Options.UnclassifiedDefaultToSymbols = true;
            Assert.AreEqual(" symbol symbol ", colorizer.Transform(" abc def "));

            LanguageRules.Symbols = new List <string>()
            {
                "abc"
            };
            colorizer = GetColorizer(LanguageRules);
            colorizer.Options.TokenFormat = "{1}";
            Assert.AreEqual(" symbol def ", colorizer.Transform(" abc def "));

            LanguageRules.Symbols = null;
        }
예제 #7
0
        public void TestEmptyLanguage()
        {
            CodeColorizer colorizer = GetColorizer(new LanguageRules
            {
                CaseSensitive    = false,
                SymbolFirstChars = null,
                SymbolChars      = null,
                OperatorChars    = null,
            });

            Assert.AreEqual("string s = new string(); //", colorizer.Transform("string s = new string(); //"));
        }
예제 #8
0
        public void BasicTest()
        {
            CodeColorizer colorizer = GetColorizer(LanguageRules);

            Assert.AreEqual(ColoredCode, colorizer.Transform(SampleCode));
        }