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

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

Issue 1502503004: Remove kuint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint8
Patch Set: rebase Created 5 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
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 <limits>
6
6 #include "base/logging.h" 7 #include "base/logging.h"
7 #include "net/base/int128.h" 8 #include "net/base/int128.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10
11 TEST(Int128, AllTests) { 11 TEST(Int128, AllTests) {
12 uint128 zero(0); 12 uint128 zero(0);
13 uint128 one(1); 13 uint128 one(1);
14 uint128 one_2arg(0, 1); 14 uint128 one_2arg(0, 1);
15 uint128 two(0, 2); 15 uint128 two(0, 2);
16 uint128 three(0, 3); 16 uint128 three(0, 3);
17 uint128 big(2000, 2); 17 uint128 big(2000, 2);
18 uint128 big_minus_one(2000, 1); 18 uint128 big_minus_one(2000, 1);
19 uint128 bigger(2001, 1); 19 uint128 bigger(2001, 1);
20 uint128 biggest(kuint128max); 20 uint128 biggest(kuint128max);
21 uint128 high_low(1, 0); 21 uint128 high_low(1, 0);
22 uint128 low_high(0, kuint64max); 22 uint128 low_high(0, std::numeric_limits<uint64_t>::max());
mmenke 2015/12/07 16:06:51 Should probably include stdint.h in this file, too
Avi (use Gerrit) 2015/12/07 16:30:06 Done.
23 EXPECT_LT(one, two); 23 EXPECT_LT(one, two);
24 EXPECT_GT(two, one); 24 EXPECT_GT(two, one);
25 EXPECT_LT(one, big); 25 EXPECT_LT(one, big);
26 EXPECT_LT(one, big); 26 EXPECT_LT(one, big);
27 EXPECT_EQ(one, one_2arg); 27 EXPECT_EQ(one, one_2arg);
28 EXPECT_NE(one, two); 28 EXPECT_NE(one, two);
29 EXPECT_GT(big, one); 29 EXPECT_GT(big, one);
30 EXPECT_GE(big, two); 30 EXPECT_GE(big, two);
31 EXPECT_GE(big, big_minus_one); 31 EXPECT_GE(big, big_minus_one);
32 EXPECT_GT(big, big_minus_one); 32 EXPECT_GT(big, big_minus_one);
(...skipping 18 matching lines...) Expand all
51 EXPECT_EQ(big, big << 0); 51 EXPECT_EQ(big, big << 0);
52 EXPECT_EQ(big, big >> 0); 52 EXPECT_EQ(big, big >> 0);
53 EXPECT_GT(big << 1, big); 53 EXPECT_GT(big << 1, big);
54 EXPECT_LT(big >> 1, big); 54 EXPECT_LT(big >> 1, big);
55 EXPECT_EQ(big, (big << 10) >> 10); 55 EXPECT_EQ(big, (big << 10) >> 10);
56 EXPECT_EQ(big, (big >> 1) << 1); 56 EXPECT_EQ(big, (big >> 1) << 1);
57 EXPECT_EQ(one, (one << 80) >> 80); 57 EXPECT_EQ(one, (one << 80) >> 80);
58 EXPECT_EQ(zero, (one >> 80) << 80); 58 EXPECT_EQ(zero, (one >> 80) << 80);
59 EXPECT_EQ(zero, big >> 128); 59 EXPECT_EQ(zero, big >> 128);
60 EXPECT_EQ(zero, big << 128); 60 EXPECT_EQ(zero, big << 128);
61 EXPECT_EQ(Uint128High64(biggest), kuint64max); 61 EXPECT_EQ(Uint128High64(biggest), std::numeric_limits<uint64_t>::max());
62 EXPECT_EQ(Uint128Low64(biggest), kuint64max); 62 EXPECT_EQ(Uint128Low64(biggest), std::numeric_limits<uint64_t>::max());
63 EXPECT_EQ(zero + one, one); 63 EXPECT_EQ(zero + one, one);
64 EXPECT_EQ(one + one, two); 64 EXPECT_EQ(one + one, two);
65 EXPECT_EQ(big_minus_one + one, big); 65 EXPECT_EQ(big_minus_one + one, big);
66 EXPECT_EQ(one - one, zero); 66 EXPECT_EQ(one - one, zero);
67 EXPECT_EQ(one - zero, one); 67 EXPECT_EQ(one - zero, one);
68 EXPECT_EQ(zero - one, biggest); 68 EXPECT_EQ(zero - one, biggest);
69 EXPECT_EQ(big - big, zero); 69 EXPECT_EQ(big - big, zero);
70 EXPECT_EQ(big - one, big_minus_one); 70 EXPECT_EQ(big - one, big_minus_one);
71 EXPECT_EQ(big + kuint64max, bigger); 71 EXPECT_EQ(big + std::numeric_limits<uint64_t>::max(), bigger);
72 EXPECT_EQ(biggest + 1, zero); 72 EXPECT_EQ(biggest + 1, zero);
73 EXPECT_EQ(zero - 1, biggest); 73 EXPECT_EQ(zero - 1, biggest);
74 EXPECT_EQ(high_low - one, low_high); 74 EXPECT_EQ(high_low - one, low_high);
75 EXPECT_EQ(low_high + one, high_low); 75 EXPECT_EQ(low_high + one, high_low);
76 EXPECT_EQ(Uint128High64((uint128(1) << 64) - 1), 0u); 76 EXPECT_EQ(Uint128High64((uint128(1) << 64) - 1), 0u);
77 EXPECT_EQ(Uint128Low64((uint128(1) << 64) - 1), kuint64max); 77 EXPECT_EQ(Uint128Low64((uint128(1) << 64) - 1),
78 std::numeric_limits<uint64_t>::max());
78 EXPECT_TRUE(!!one); 79 EXPECT_TRUE(!!one);
79 EXPECT_TRUE(!!high_low); 80 EXPECT_TRUE(!!high_low);
80 EXPECT_FALSE(!!zero); 81 EXPECT_FALSE(!!zero);
81 EXPECT_FALSE(!one); 82 EXPECT_FALSE(!one);
82 EXPECT_FALSE(!high_low); 83 EXPECT_FALSE(!high_low);
83 EXPECT_TRUE(!zero); 84 EXPECT_TRUE(!zero);
84 EXPECT_TRUE(zero == 0); 85 EXPECT_TRUE(zero == 0);
85 EXPECT_FALSE(zero != 0); 86 EXPECT_FALSE(zero != 0);
86 EXPECT_FALSE(one == 0); 87 EXPECT_FALSE(one == 0);
87 EXPECT_TRUE(one != 0); 88 EXPECT_TRUE(one != 0);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 uint128 x1(1, 2); 251 uint128 x1(1, 2);
251 uint128 x2(2, 4); 252 uint128 x2(2, 4);
252 x1 += x1; 253 x1 += x1;
253 EXPECT_EQ(x2, x1); 254 EXPECT_EQ(x2, x1);
254 255
255 uint128 x3(1, 1ull << 63); 256 uint128 x3(1, 1ull << 63);
256 uint128 x4(3, 0); 257 uint128 x4(3, 0);
257 x3 += x3; 258 x3 += x3;
258 EXPECT_EQ(x4, x3); 259 EXPECT_EQ(x4, x3);
259 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698