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

Side by Side Diff: base/string_number_conversions_unittest.cc

Issue 11568033: Small fixes to allow unit tests to compile with gcc 4.7.x (tested with gcc 4.7.2) (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « base/pickle_unittest.cc ('k') | chrome/browser/password_manager/password_store_x_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <math.h> 5 #include <math.h>
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 string16 utf16_input = UTF8ToUTF16(input_string); 197 string16 utf16_input = UTF8ToUTF16(input_string);
198 output = 0; 198 output = 0;
199 EXPECT_FALSE(StringToInt64(utf16_input, &output)); 199 EXPECT_FALSE(StringToInt64(utf16_input, &output));
200 EXPECT_EQ(6, output); 200 EXPECT_EQ(6, output);
201 } 201 }
202 202
203 TEST(StringNumberConversionsTest, HexStringToInt) { 203 TEST(StringNumberConversionsTest, HexStringToInt) {
204 static const struct { 204 static const struct {
205 std::string input; 205 std::string input;
206 int output; 206 int64 output;
207 bool success; 207 bool success;
208 } cases[] = { 208 } cases[] = {
209 {"0", 0, true}, 209 {"0", 0, true},
210 {"42", 66, true}, 210 {"42", 66, true},
211 {"-42", -66, true}, 211 {"-42", -66, true},
212 {"+42", 66, true}, 212 {"+42", 66, true},
213 {"7fffffff", INT_MAX, true}, 213 {"7fffffff", INT_MAX, true},
214 {"80000000", INT_MIN, true}, 214 {"80000000", INT_MIN, true},
215 {"ffffffff", -1, true}, 215 {"ffffffff", -1, true},
216 {"DeadBeef", 0xdeadbeef, true}, 216 {"DeadBeef", 0xdeadbeef, true},
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 TEST(StringNumberConversionsTest, HexEncode) { 377 TEST(StringNumberConversionsTest, HexEncode) {
378 std::string hex(HexEncode(NULL, 0)); 378 std::string hex(HexEncode(NULL, 0));
379 EXPECT_EQ(hex.length(), 0U); 379 EXPECT_EQ(hex.length(), 0U);
380 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; 380 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81};
381 hex = HexEncode(bytes, sizeof(bytes)); 381 hex = HexEncode(bytes, sizeof(bytes));
382 EXPECT_EQ(hex.compare("01FF02FE038081"), 0); 382 EXPECT_EQ(hex.compare("01FF02FE038081"), 0);
383 } 383 }
384 384
385 } // namespace base 385 } // namespace base
OLDNEW
« no previous file with comments | « base/pickle_unittest.cc ('k') | chrome/browser/password_manager/password_store_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698