| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "platform/utils.h" | 6 #include "platform/utils.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 | 119 |
| 120 UNIT_TEST_CASE(CountZeros) { | 120 UNIT_TEST_CASE(CountZeros) { |
| 121 EXPECT_EQ(0, Utils::CountTrailingZeros(0x1)); | 121 EXPECT_EQ(0, Utils::CountTrailingZeros(0x1)); |
| 122 EXPECT_EQ(kBitsPerWord - 1, Utils::CountLeadingZeros(0x1)); | 122 EXPECT_EQ(kBitsPerWord - 1, Utils::CountLeadingZeros(0x1)); |
| 123 EXPECT_EQ(1, Utils::CountTrailingZeros(0x2)); | 123 EXPECT_EQ(1, Utils::CountTrailingZeros(0x2)); |
| 124 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x2)); | 124 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x2)); |
| 125 EXPECT_EQ(0, Utils::CountTrailingZeros(0x3)); | 125 EXPECT_EQ(0, Utils::CountTrailingZeros(0x3)); |
| 126 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x3)); | 126 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x3)); |
| 127 EXPECT_EQ(2, Utils::CountTrailingZeros(0x4)); | 127 EXPECT_EQ(2, Utils::CountTrailingZeros(0x4)); |
| 128 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x4)); | 128 EXPECT_EQ(kBitsPerWord - 3, Utils::CountLeadingZeros(0x4)); |
| 129 EXPECT_EQ(0, Utils::CountTrailingZeros(kUwordMax)); | 129 EXPECT_EQ(0, Utils::CountTrailingZeros(kUwordMax)); |
| 130 EXPECT_EQ(0, Utils::CountLeadingZeros(kUwordMax)); | 130 EXPECT_EQ(0, Utils::CountLeadingZeros(kUwordMax)); |
| 131 static const uword kTopBit = static_cast<uword>(1) << (kBitsPerWord - 1); | 131 static const uword kTopBit = static_cast<uword>(1) << (kBitsPerWord - 1); |
| 132 EXPECT_EQ(kBitsPerWord - 1, Utils::CountTrailingZeros(kTopBit)); | 132 EXPECT_EQ(kBitsPerWord - 1, Utils::CountTrailingZeros(kTopBit)); |
| 133 EXPECT_EQ(0, Utils::CountLeadingZeros(kTopBit)); | 133 EXPECT_EQ(0, Utils::CountLeadingZeros(kTopBit)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 UNIT_TEST_CASE(IsInt) { | 137 UNIT_TEST_CASE(IsInt) { |
| 138 EXPECT(Utils::IsInt(8, 16)); | 138 EXPECT(Utils::IsInt(8, 16)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 UNIT_TEST_CASE(DoublesBitEqual) { | 240 UNIT_TEST_CASE(DoublesBitEqual) { |
| 241 EXPECT(Utils::DoublesBitEqual(1.0, 1.0)); | 241 EXPECT(Utils::DoublesBitEqual(1.0, 1.0)); |
| 242 EXPECT(!Utils::DoublesBitEqual(1.0, -1.0)); | 242 EXPECT(!Utils::DoublesBitEqual(1.0, -1.0)); |
| 243 EXPECT(Utils::DoublesBitEqual(0.0, 0.0)); | 243 EXPECT(Utils::DoublesBitEqual(0.0, 0.0)); |
| 244 EXPECT(!Utils::DoublesBitEqual(0.0, -0.0)); | 244 EXPECT(!Utils::DoublesBitEqual(0.0, -0.0)); |
| 245 EXPECT(Utils::DoublesBitEqual(NAN, NAN)); | 245 EXPECT(Utils::DoublesBitEqual(NAN, NAN)); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace dart | 248 } // namespace dart |
| OLD | NEW |