OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 <cstdint> | 5 #include <cstdint> |
6 | 6 |
7 #include "src/base/logging.h" | 7 #include "src/base/logging.h" |
8 #include "src/objects.h" | 8 #include "src/objects.h" |
9 #include "testing/gtest-support.h" | 9 #include "testing/gtest-support.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 #define CHECK_SUCCEED(NAME, lhs, rhs) \ | 16 #define CHECK_SUCCEED(NAME, lhs, rhs) \ |
17 { \ | 17 { \ |
18 std::string* error_message = \ | 18 std::string* error_message = \ |
19 Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \ | 19 Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \ |
20 EXPECT_EQ(nullptr, error_message); \ | 20 EXPECT_EQ(nullptr, error_message); \ |
21 } | 21 } |
22 | 22 |
23 #define CHECK_FAIL(NAME, lhs, rhs) \ | 23 #define CHECK_FAIL(NAME, lhs, rhs) \ |
24 { \ | 24 { \ |
25 std::string* error_message = \ | 25 std::string* error_message = \ |
26 Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \ | 26 Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \ |
27 EXPECT_NE(nullptr, error_message); \ | 27 EXPECT_NE(nullptr, error_message); \ |
| 28 delete error_message; \ |
28 } | 29 } |
29 | 30 |
30 } // namespace | 31 } // namespace |
31 | 32 |
32 TEST(LoggingTest, CheckEQImpl) { | 33 TEST(LoggingTest, CheckEQImpl) { |
33 CHECK_SUCCEED(EQ, 0.0, 0.0) | 34 CHECK_SUCCEED(EQ, 0.0, 0.0) |
34 CHECK_SUCCEED(EQ, 0.0, -0.0) | 35 CHECK_SUCCEED(EQ, 0.0, -0.0) |
35 CHECK_SUCCEED(EQ, -0.0, 0.0) | 36 CHECK_SUCCEED(EQ, -0.0, 0.0) |
36 CHECK_SUCCEED(EQ, -0.0, -0.0) | 37 CHECK_SUCCEED(EQ, -0.0, -0.0) |
37 } | 38 } |
(...skipping 19 matching lines...) Expand all Loading... |
57 } | 58 } |
58 | 59 |
59 TEST(LoggingTest, CompareAgainstStaticConstPointer) { | 60 TEST(LoggingTest, CompareAgainstStaticConstPointer) { |
60 // These used to produce link errors before http://crrev.com/2524093002. | 61 // These used to produce link errors before http://crrev.com/2524093002. |
61 CHECK_FAIL(EQ, v8::internal::Smi::kZero, v8::internal::Smi::FromInt(17)); | 62 CHECK_FAIL(EQ, v8::internal::Smi::kZero, v8::internal::Smi::FromInt(17)); |
62 CHECK_SUCCEED(GT, 0, v8::internal::Smi::kMinValue); | 63 CHECK_SUCCEED(GT, 0, v8::internal::Smi::kMinValue); |
63 } | 64 } |
64 | 65 |
65 } // namespace base | 66 } // namespace base |
66 } // namespace v8 | 67 } // namespace v8 |
OLD | NEW |