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

Side by Side Diff: trunk/src/net/base/int128_unittest.cc

Issue 227743006: Revert 262147 "Remove all uses of GG_LONGLONG and GG_ULONGLONG." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/net/base/int128.cc ('k') | trunk/src/sql/meta_table_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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "net/base/int128.h" 7 #include "net/base/int128.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 for (int i = 0; i < 64; ++i) { 223 for (int i = 0; i < 64; ++i) {
224 for (int j = 0; j < 64; ++j) { 224 for (int j = 0; j < 64; ++j) {
225 a = uint128(1) << i; 225 a = uint128(1) << i;
226 b = uint128(1) << j; 226 b = uint128(1) << j;
227 c = a * b; 227 c = a * b;
228 EXPECT_EQ(uint128(1) << (i+j), c); 228 EXPECT_EQ(uint128(1) << (i+j), c);
229 } 229 }
230 } 230 }
231 231
232 // Verified with dc. 232 // Verified with dc.
233 a = uint128(0xffffeeeeddddccccULL, 0xbbbbaaaa99998888ULL); 233 a = uint128(GG_ULONGLONG(0xffffeeeeddddcccc),
234 b = uint128(0x7777666655554444ULL, 0x3333222211110000ULL); 234 GG_ULONGLONG(0xbbbbaaaa99998888));
235 b = uint128(GG_ULONGLONG(0x7777666655554444),
236 GG_ULONGLONG(0x3333222211110000));
235 c = a * b; 237 c = a * b;
236 EXPECT_EQ(uint128(0x530EDA741C71D4C3ULL, 0xBF25975319080000ULL), c); 238 EXPECT_EQ(uint128(GG_ULONGLONG(0x530EDA741C71D4C3),
239 GG_ULONGLONG(0xBF25975319080000)), c);
237 EXPECT_EQ(0, c - b * a); 240 EXPECT_EQ(0, c - b * a);
238 EXPECT_EQ(a*a - b*b, (a+b) * (a-b)); 241 EXPECT_EQ(a*a - b*b, (a+b) * (a-b));
239 242
240 // Verified with dc. 243 // Verified with dc.
241 a = uint128(0x0123456789abcdefULL, 0xfedcba9876543210ULL); 244 a = uint128(GG_ULONGLONG(0x0123456789abcdef),
242 b = uint128(0x02468ace13579bdfULL, 0xfdb97531eca86420ULL); 245 GG_ULONGLONG(0xfedcba9876543210));
246 b = uint128(GG_ULONGLONG(0x02468ace13579bdf),
247 GG_ULONGLONG(0xfdb97531eca86420));
243 c = a * b; 248 c = a * b;
244 EXPECT_EQ(uint128(0x97a87f4f261ba3f2ULL, 0x342d0bbf48948200ULL), c); 249 EXPECT_EQ(uint128(GG_ULONGLONG(0x97a87f4f261ba3f2),
250 GG_ULONGLONG(0x342d0bbf48948200)), c);
245 EXPECT_EQ(0, c - b * a); 251 EXPECT_EQ(0, c - b * a);
246 EXPECT_EQ(a*a - b*b, (a+b) * (a-b)); 252 EXPECT_EQ(a*a - b*b, (a+b) * (a-b));
247 } 253 }
248 254
249 TEST(Int128, AliasTests) { 255 TEST(Int128, AliasTests) {
250 uint128 x1(1, 2); 256 uint128 x1(1, 2);
251 uint128 x2(2, 4); 257 uint128 x2(2, 4);
252 x1 += x1; 258 x1 += x1;
253 EXPECT_EQ(x2, x1); 259 EXPECT_EQ(x2, x1);
254 260
255 uint128 x3(1, 1ull << 63); 261 uint128 x3(1, 1ull << 63);
256 uint128 x4(3, 0); 262 uint128 x4(3, 0);
257 x3 += x3; 263 x3 += x3;
258 EXPECT_EQ(x4, x3); 264 EXPECT_EQ(x4, x3);
259 } 265 }
OLDNEW
« no previous file with comments | « trunk/src/net/base/int128.cc ('k') | trunk/src/sql/meta_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698