Esempio n. 1
0
        public void CssToken_EndOfFileTokenTest()
        {
            CssToken eof = CssToken.EndOfFileToken();

            Assert.AreEqual(0, eof.Start);
            Assert.AreEqual(0, eof.Length);
            Assert.AreEqual(CssTokenType.EndOfFile, eof.TokenType);

            eof = CssToken.EndOfFileToken(new StringTextProvider("abc"));
            Assert.AreEqual(3, eof.Start);
            Assert.AreEqual(0, eof.Length);
            Assert.AreEqual(CssTokenType.EndOfFile, eof.TokenType);
        }
Esempio n. 2
0
        public void TokenizerTest_EncodedUrl()
        {
            CssTokenizer tokenizer = new CssTokenizer();

            // Base case: No encoding:
            ITextProvider text   = new StringTextProvider(@"url('foo.jpg')");
            TokenList     actual = Helpers.MakeTokens(text);

            TokenizeFilesTest.CompareTokenArrays(
                new CssToken[]
            {
                new CssToken(CssTokenType.Url, 0, 4),
                new CssToken(CssTokenType.String, 4, 9),
                new CssToken(CssTokenType.CloseFunctionBrace, 13, 1),
                CssToken.EndOfFileToken(text)
            },
                actual);

#if SUPPORT_ENCODED_CSS
            // Escape characters:
            text   = new StringTextProvider(@"\u\r\l('foo.jpg')");
            actual = Helpers.MakeTokens(text.GetText(0, text.Length));

            TokenizeFilesTest.CompareTokenArrays(
                new CssToken[]
            {
                new CssToken(CssTokenType.Url, 0, 7),
                new CssToken(CssTokenType.String, 7, 9),
                new CssToken(CssTokenType.CloseFunctionBrace, 16, 1),
                CssToken.EndOfFileToken(text)
            },
                actual);

            // Unicode encode and escape characters:
            text   = new StringTextProvider(@"u\52 \l(foo)");
            actual = Helpers.MakeTokens(text.GetText(0, text.Length));

            TokenizeFilesTest.CompareTokenArrays(
                new CssToken[]
            {
                new CssToken(CssTokenType.Url, 0, 8),
                new CssToken(CssTokenType.UnquotedUrlString, 8, 3),
                new CssToken(CssTokenType.CloseFunctionBrace, 11, 1),
                CssToken.EndOfFileToken(text)
            },
                actual);
#endif
        }
Esempio n. 3
0
        public void TokenizerTest_AtDirective()
        {
            ITextProvider text = new StringTextProvider("@charset \"iso-1234\";");

            CssToken[] expected = new CssToken[]
            {
                new CssToken(CssTokenType.At, 0, 1),
                new CssToken(CssTokenType.Identifier, 1, 7),
                new CssToken(CssTokenType.String, 9, 10),
                new CssToken(CssTokenType.Semicolon, 19, 1),
                CssToken.EndOfFileToken(text)
            };

            TokenList actual = Helpers.MakeTokens(text);

            TokenizeFilesTest.CompareTokenArrays(expected, actual);
        }
Esempio n. 4
0
 private void RunTest(string input, IList <CssToken> expectedTokens)
 {
     expectedTokens.Add(CssToken.EndOfFileToken(new StringTextProvider(input)));
     VerifyTokens(input, expectedTokens);
 }