Commit db5015ef authored by yoav@yoav.ws's avatar yoav@yoav.ws

Fixed an assert related to MediaQuerytokenizer code points table

The assert was a result of an off-by-one error in both the array's definition and the assert itself.

BUG=353577

Review URL: https://codereview.chromium.org/203343004

git-svn-id: svn://svn.chromium.org/blink/trunk@169494 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 63a5addc
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
namespace WebCore { namespace WebCore {
const unsigned codePointsNumber = SCHAR_MAX; const unsigned codePointsNumber = SCHAR_MAX + 1;
class MediaQueryTokenizer::CodePoints { class MediaQueryTokenizer::CodePoints {
public: public:
......
...@@ -24,4 +24,46 @@ TEST(MediaQueryTokenizerTest, Basic) ...@@ -24,4 +24,46 @@ TEST(MediaQueryTokenizerTest, Basic)
} }
} }
void testToken(UChar c, MediaQueryTokenType tokenType)
{
Vector<MediaQueryToken> tokens;
StringBuilder input;
input.append(c);
MediaQueryTokenizer::tokenize(input.toString(), tokens);
ASSERT_EQ(tokens[0].type(), tokenType);
}
TEST(MediaQueryTokenizerCodepointsTest, Basic)
{
for (UChar c = 0; c <= 1000; ++c) {
if (isASCIIDigit(c))
testToken(c, NumberToken);
else if (isASCIIAlpha(c))
testToken(c, IdentToken);
else if (c == '_')
testToken(c, IdentToken);
else if (c == '\r' || c == ' ' || c == '\n' || c == '\t' || c == '\f')
testToken(c, WhitespaceToken);
else if (c == '(')
testToken(c, LeftParenthesisToken);
else if (c == ')')
testToken(c, RightParenthesisToken);
else if (c == '.' || c == '+' || c == '-' || c == '/' || c == '\\')
testToken(c, DelimiterToken);
else if (c == ',')
testToken(c, CommaToken);
else if (c == ':')
testToken(c, ColonToken);
else if (c == ';')
testToken(c, SemicolonToken);
else if (!c)
testToken(c, EOFToken);
else if (c > SCHAR_MAX)
testToken(c, IdentToken);
else
testToken(c, DelimiterToken);
}
testToken(USHRT_MAX, IdentToken);
}
} // namespace } // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment