Bug 241788 - mozilla::Tokenizer - token type for \n should whitespace if given in constructor r=honzab

This commit is contained in:
Valentin Gosu 2016-02-05 14:43:45 +01:00
parent f2674e1627
commit e8d450bb24
2 changed files with 17 additions and 2 deletions

View File

@ -260,12 +260,12 @@ Tokenizer::Parse(Token& aToken) const
state = PARSE_WORD;
} else if (IsNumber(*next)) {
state = PARSE_INTEGER;
} else if (strchr(mWhitespaces, *next)) { // not UTF-8 friendly?
state = PARSE_WS;
} else if (*next == '\r') {
state = PARSE_CRLF;
} else if (*next == '\n') {
state = PARSE_LF;
} else if (strchr(mWhitespaces, *next)) { // not UTF-8 friendly?
state = PARSE_WS;
} else {
state = PARSE_CHAR;
}

View File

@ -526,6 +526,21 @@ TEST(Tokenizer, SkipWhites)
EXPECT_TRUE(p.CheckEOF());
}
TEST(Tokenizer, SkipCustomWhites)
{
Tokenizer p("Text1 \n\r\t.Text2 \n\r\t.", " \n\r\t.");
EXPECT_TRUE(p.CheckWord("Text1"));
p.SkipWhites();
EXPECT_TRUE(p.CheckWord("Text2"));
EXPECT_TRUE(p.CheckWhite());
EXPECT_TRUE(p.CheckWhite());
EXPECT_TRUE(p.CheckWhite());
EXPECT_TRUE(p.CheckWhite());
EXPECT_TRUE(p.CheckWhite());
EXPECT_TRUE(p.CheckEOF());
}
TEST(Tokenizer, IntegerReading)
{
#define INT_6_BITS 64U