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

Side by Side Diff: Source/core/css/parser/MediaQueryCalcParserTest.cpp

Issue 252743004: A thread safe CSS calc parser for sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: removed linespace Created 6 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/css/parser/MediaQueryCalcParser.h"
7
8 #include "core/css/parser/MediaQueryTokenizer.h"
9
10 #include <gtest/gtest.h>
11
12 namespace WebCore {
13
14 typedef struct {
15 const char* input;
16 const int output;
17 } TestCase;
18
19 TEST(MediaQueryCalcParserTest, Basic)
20 {
21 // The first string represents the input string.
22 // The second string represents the output string, if present.
23 // Otherwise, the output string is identical to the first string.
24 TestCase testCases[] = {
25 {"calc(500px + 10em)", 660},
26 {"calc(500px + 2 * 10em)", 820},
27 {"calc(500px + 2*10em)", 820},
28 {"calc(500px + 50%*10em)", 580},
29 {"calc(500px + (50%*10em + 13px))", 593},
30 {"calc(100vw + (50%*10em + 13px))", 593},
31 {"calc(100vh + (50%*10em + 13px))", 736},
32 {0, 0} // Do not remove the terminator line.
33 };
34
35
36 for (unsigned i = 0; testCases[i].input; ++i) {
37 Vector<MediaQueryToken> tokens;
38 MediaQueryTokenizer::tokenize(testCases[i].input, tokens);
39 int output = MediaQueryCalcParser::parse(tokens.begin(), tokens.end(), 1 6, 500, 643);
40 ASSERT_EQ(testCases[i].output, output);
41 }
42 }
43
44 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698