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

Side by Side Diff: base/string_util_unittest.cc

Issue 160191: Move base::va_copy from a function to a macro. (Closed)
Patch Set: Created 11 years, 4 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
« base/port.h ('K') | « base/string_util.cc ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include <stdarg.h> 6 #include <stdarg.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 1295
1296 // This checks where we can use the assignment operator for a va_list. We need 1296 // This checks where we can use the assignment operator for a va_list. We need
1297 // a way to do this since Visual C doesn't support va_copy, but assignment on 1297 // a way to do this since Visual C doesn't support va_copy, but assignment on
1298 // va_list is not guaranteed to be a copy. See StringAppendVT which uses this 1298 // va_list is not guaranteed to be a copy. See StringAppendVT which uses this
1299 // capability. 1299 // capability.
1300 static void VariableArgsFunc(const char* format, ...) { 1300 static void VariableArgsFunc(const char* format, ...) {
1301 va_list org; 1301 va_list org;
1302 va_start(org, format); 1302 va_start(org, format);
1303 1303
1304 va_list dup; 1304 va_list dup;
1305 base::va_copy(dup, org); 1305 GG_VA_COPY(dup, org);
1306 int i1 = va_arg(org, int); 1306 int i1 = va_arg(org, int);
1307 int j1 = va_arg(org, int); 1307 int j1 = va_arg(org, int);
1308 char* s1 = va_arg(org, char*); 1308 char* s1 = va_arg(org, char*);
1309 double d1 = va_arg(org, double); 1309 double d1 = va_arg(org, double);
1310 va_end(org); 1310 va_end(org);
1311 1311
1312 int i2 = va_arg(dup, int); 1312 int i2 = va_arg(dup, int);
1313 int j2 = va_arg(dup, int); 1313 int j2 = va_arg(dup, int);
1314 char* s2 = va_arg(dup, char*); 1314 char* s2 = va_arg(dup, char*);
1315 double d2 = va_arg(dup, double); 1315 double d2 = va_arg(dup, double);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 } 1801 }
1802 } 1802 }
1803 1803
1804 TEST(StringUtilTest, HexEncode) { 1804 TEST(StringUtilTest, HexEncode) {
1805 std::string hex(HexEncode(NULL, 0)); 1805 std::string hex(HexEncode(NULL, 0));
1806 EXPECT_EQ(hex.length(), 0U); 1806 EXPECT_EQ(hex.length(), 0U);
1807 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; 1807 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81};
1808 hex = HexEncode(bytes, sizeof(bytes)); 1808 hex = HexEncode(bytes, sizeof(bytes));
1809 EXPECT_EQ(hex.compare("01FF02FE038081"), 0); 1809 EXPECT_EQ(hex.compare("01FF02FE038081"), 0);
1810 } 1810 }
OLDNEW
« base/port.h ('K') | « base/string_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698