OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "core/css/parser/CSSParserToken.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace blink { | |
10 | |
11 static CSSParserString toParserString(const String& string) | |
12 { | |
13 CSSParserString result; | |
14 result.init(string); | |
esprehn
2016/05/09 21:59:54
we should just add explicit constructors to CSSPar
ikilpatrick
2016/05/10 20:39:37
Acknowledged.
| |
15 return result; | |
16 } | |
17 | |
18 static CSSParserToken ident(const String& string) { return CSSParserToken(IdentT oken, toParserString(string)); } | |
19 static CSSParserToken dimension(double value, const String& unit) | |
20 { | |
21 CSSParserToken token(NumberToken, value, NumberValueType, NoSign); | |
22 token.convertToDimensionWithUnit(toParserString(unit)); | |
23 return token; | |
24 } | |
25 | |
26 TEST(CSSParserTokenTest, IdentTokenEquality) | |
27 { | |
28 String foo8Bit("foo"); | |
29 String bar8Bit("bar"); | |
30 String foo16Bit = String::make16BitFrom8BitSource(foo8Bit.characters8(), foo 8Bit.length()); | |
31 | |
32 EXPECT_EQ(ident(foo8Bit), ident(foo16Bit)); | |
33 EXPECT_EQ(ident(foo16Bit), ident(foo8Bit)); | |
34 EXPECT_EQ(ident(foo16Bit), ident(foo16Bit)); | |
35 EXPECT_NE(ident(bar8Bit), ident(foo8Bit)); | |
36 EXPECT_NE(ident(bar8Bit), ident(foo16Bit)); | |
37 } | |
38 | |
39 TEST(CSSParserTokenTest, DimensionTokenEquality) | |
40 { | |
41 String em8Bit("em"); | |
42 String rem8Bit("rem"); | |
43 String em16Bit = String::make16BitFrom8BitSource(em8Bit.characters8(), em8Bi t.length()); | |
44 | |
45 EXPECT_EQ(dimension(1, em8Bit), dimension(1, em16Bit)); | |
46 EXPECT_EQ(dimension(1, em8Bit), dimension(1, em8Bit)); | |
47 EXPECT_NE(dimension(1, em8Bit), dimension(1, rem8Bit)); | |
48 EXPECT_NE(dimension(2, em8Bit), dimension(1, em16Bit)); | |
49 } | |
50 | |
51 } // namespace blink | |
OLD | NEW |