| OLD | NEW |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 EXPECT_EQ(test |= three, three); | 102 EXPECT_EQ(test |= three, three); |
| 103 EXPECT_EQ(test &= one, one); | 103 EXPECT_EQ(test &= one, one); |
| 104 EXPECT_EQ(test ^= three, two); | 104 EXPECT_EQ(test ^= three, two); |
| 105 EXPECT_EQ(test >>= 1, one); | 105 EXPECT_EQ(test >>= 1, one); |
| 106 EXPECT_EQ(test <<= 1, two); | 106 EXPECT_EQ(test <<= 1, two); |
| 107 | 107 |
| 108 EXPECT_EQ(big, -(-big)); | 108 EXPECT_EQ(big, -(-big)); |
| 109 EXPECT_EQ(two, -((-one) - 1)); | 109 EXPECT_EQ(two, -((-one) - 1)); |
| 110 EXPECT_EQ(kuint128max, -one); | 110 EXPECT_EQ(kuint128max, -one); |
| 111 EXPECT_EQ(zero, -zero); | 111 EXPECT_EQ(zero, -zero); |
| 112 | |
| 113 LOG(INFO) << one; | |
| 114 LOG(INFO) << big_minus_one; | |
| 115 } | 112 } |
| 116 | 113 |
| 117 TEST(Int128, PodTests) { | 114 TEST(Int128, PodTests) { |
| 118 uint128_pod pod = { 12345, 67890 }; | 115 uint128_pod pod = { 12345, 67890 }; |
| 119 uint128 from_pod(pod); | 116 uint128 from_pod(pod); |
| 120 EXPECT_EQ(12345u, Uint128High64(from_pod)); | 117 EXPECT_EQ(12345u, Uint128High64(from_pod)); |
| 121 EXPECT_EQ(67890u, Uint128Low64(from_pod)); | 118 EXPECT_EQ(67890u, Uint128Low64(from_pod)); |
| 122 | 119 |
| 123 uint128 zero(0); | 120 uint128 zero(0); |
| 124 uint128_pod zero_pod = {0, 0}; | 121 uint128_pod zero_pod = {0, 0}; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 uint128 x1(1, 2); | 253 uint128 x1(1, 2); |
| 257 uint128 x2(2, 4); | 254 uint128 x2(2, 4); |
| 258 x1 += x1; | 255 x1 += x1; |
| 259 EXPECT_EQ(x2, x1); | 256 EXPECT_EQ(x2, x1); |
| 260 | 257 |
| 261 uint128 x3(1, 1ull << 63); | 258 uint128 x3(1, 1ull << 63); |
| 262 uint128 x4(3, 0); | 259 uint128 x4(3, 0); |
| 263 x3 += x3; | 260 x3 += x3; |
| 264 EXPECT_EQ(x4, x3); | 261 EXPECT_EQ(x4, x3); |
| 265 } | 262 } |
| OLD | NEW |