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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLParserIdiomsTest.cpp

Issue 2411713002: Fix parseHTMLInteger (Closed)
Patch Set: Try to fix warning for test Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLParserIdioms.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/parser/HTMLParserIdioms.h" 5 #include "core/html/parser/HTMLParserIdioms.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 namespace { 11 namespace {
12 12
13 TEST(HTMLParserIdiomsTest, ParseHTMLInteger) {
14 int value = 0;
15
16 EXPECT_TRUE(parseHTMLInteger("2147483646", value));
17 EXPECT_EQ(2147483646, value);
18 EXPECT_TRUE(parseHTMLInteger("2147483647", value));
19 EXPECT_EQ(2147483647, value);
20 value = 12345;
21 EXPECT_FALSE(parseHTMLInteger("2147483648", value));
22 EXPECT_EQ(12345, value);
23
24 EXPECT_TRUE(parseHTMLInteger("-2147483647", value));
25 EXPECT_EQ(-2147483647, value);
26 EXPECT_TRUE(parseHTMLInteger("-2147483648", value));
27 EXPECT_EQ(0 - 2147483648, value);
28 value = 12345;
29 EXPECT_FALSE(parseHTMLInteger("-2147483649", value));
30 EXPECT_EQ(12345, value);
31 }
32
13 TEST(HTMLParserIdiomsTest, ParseHTMLNonNegativeInteger) { 33 TEST(HTMLParserIdiomsTest, ParseHTMLNonNegativeInteger) {
14 unsigned value = 0; 34 unsigned value = 0;
15 35
16 EXPECT_TRUE(parseHTMLNonNegativeInteger("0", value)); 36 EXPECT_TRUE(parseHTMLNonNegativeInteger("0", value));
17 EXPECT_EQ(0U, value); 37 EXPECT_EQ(0U, value);
18 38
19 EXPECT_TRUE(parseHTMLNonNegativeInteger("+0", value)); 39 EXPECT_TRUE(parseHTMLNonNegativeInteger("+0", value));
20 EXPECT_EQ(0U, value); 40 EXPECT_EQ(0U, value);
21 41
22 EXPECT_TRUE(parseHTMLNonNegativeInteger("-0", value)); 42 EXPECT_TRUE(parseHTMLNonNegativeInteger("-0", value));
(...skipping 21 matching lines...) Expand all
44 } 64 }
45 65
46 TEST(HTMLParserIdiomsTest, ParseHTMLListOfFloatingPointNumbers_null) { 66 TEST(HTMLParserIdiomsTest, ParseHTMLListOfFloatingPointNumbers_null) {
47 Vector<double> numbers = parseHTMLListOfFloatingPointNumbers(nullAtom); 67 Vector<double> numbers = parseHTMLListOfFloatingPointNumbers(nullAtom);
48 EXPECT_EQ(0u, numbers.size()); 68 EXPECT_EQ(0u, numbers.size());
49 } 69 }
50 70
51 } // namespace 71 } // namespace
52 72
53 } // namespace blink 73 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLParserIdioms.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698