Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: Source/core/css/parser/CSSTokenizerTest.cpp

Issue 962093002: CSS Tokenizer: Add an on-stack tokenizer scope (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/parser/CSSTokenizer.cpp ('k') | Source/core/css/parser/MediaConditionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSTokenizerTest.cpp
diff --git a/Source/core/css/parser/CSSTokenizerTest.cpp b/Source/core/css/parser/CSSTokenizerTest.cpp
index 531b18c8e5d021397c2bdf1c83a18260a144b6d7..e3ed88bc58b2c564d483bd7f1ec0e0136de4ade8 100644
--- a/Source/core/css/parser/CSSTokenizerTest.cpp
+++ b/Source/core/css/parser/CSSTokenizerTest.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "core/css/parser/CSSTokenizer.h"
+#include "core/css/parser/CSSParserTokenRange.h"
#include "core/css/parser/MediaQueryBlockWatcher.h"
#include <gtest/gtest.h>
@@ -65,12 +66,13 @@ void testTokens(const String& string, const CSSParserToken& token1, const CSSPar
expectedTokens.append(token3);
}
- Vector<CSSParserToken> actualTokens;
- CSSTokenizer::tokenize(string, actualTokens);
+ CSSParserTokenRange expected(expectedTokens);
- ASSERT_EQ(expectedTokens.size(), actualTokens.size());
- for (size_t i = 0; i < expectedTokens.size(); ++i)
- compareTokens(expectedTokens[i], actualTokens[i]);
+ CSSTokenizer::Scope actualScope(string);
+ CSSParserTokenRange actual = actualScope.tokenRange();
+
+ while (!expected.atEnd() || !actual.atEnd())
+ compareTokens(expected.consume(), actual.consume());
}
static CSSParserToken ident(const String& string) { return CSSParserToken(IdentToken, string); }
@@ -455,14 +457,14 @@ TEST(CSSTokenizerBlockTest, Basic)
{0, 0, 0} // Do not remove the terminator line.
};
for (int i = 0; testCases[i].input; ++i) {
- Vector<CSSParserToken> tokens;
- CSSTokenizer::tokenize(testCases[i].input, tokens);
+ CSSTokenizer::Scope scope(testCases[i].input);
+ CSSParserTokenRange range = scope.tokenRange();
MediaQueryBlockWatcher blockWatcher;
unsigned maxLevel = 0;
unsigned level = 0;
- for (size_t j = 0; j < tokens.size(); ++j) {
- blockWatcher.handleToken(tokens[j]);
+ while (!range.atEnd()) {
+ blockWatcher.handleToken(range.consume());
level = blockWatcher.blockLevel();
maxLevel = std::max(level, maxLevel);
}
« no previous file with comments | « Source/core/css/parser/CSSTokenizer.cpp ('k') | Source/core/css/parser/MediaConditionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698