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

Side by Side Diff: test/unittests/base/logging-unittest.cc

Issue 2526783002: [base] Define CHECK comparison for signed vs. unsigned (Closed)
Patch Set: Extend test case Created 4 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
« no previous file with comments | « src/wasm/wasm-text.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/base/logging.h" 5 #include "src/base/logging.h"
6 #include "testing/gtest-support.h" 6 #include "testing/gtest-support.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace base { 9 namespace base {
10 10
11 namespace { 11 namespace {
12 template <typename Lhs, typename Rhs> 12
13 std::string *CallCheckEQ(Lhs lhs, Rhs rhs, const char *msg) { 13 #define CHECK_SUCCEED(NAME, lhs, rhs) \
14 return CheckEQImpl<Lhs, Rhs>(lhs, rhs, msg); 14 { \
15 } 15 std::string* error_message = \
16 Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \
17 EXPECT_EQ(nullptr, error_message); \
18 }
19
20 #define CHECK_FAIL(NAME, lhs, rhs) \
21 { \
22 std::string* error_message = \
23 Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \
24 EXPECT_NE(nullptr, error_message); \
25 }
26
16 } // namespace 27 } // namespace
17 28
18 TEST(LoggingTest, CheckEQImpl) { 29 TEST(LoggingTest, CheckEQImpl) {
19 EXPECT_EQ(nullptr, CallCheckEQ(0.0, 0.0, "")); 30 CHECK_SUCCEED(EQ, 0.0, 0.0)
20 EXPECT_EQ(nullptr, CallCheckEQ(0.0, -0.0, "")); 31 CHECK_SUCCEED(EQ, 0.0, -0.0)
21 EXPECT_EQ(nullptr, CallCheckEQ(-0.0, 0.0, "")); 32 CHECK_SUCCEED(EQ, -0.0, 0.0)
22 EXPECT_EQ(nullptr, CallCheckEQ(-0.0, -0.0, "")); 33 CHECK_SUCCEED(EQ, -0.0, -0.0)
Igor Sheludko 2016/11/29 14:12:04 Maybe also test a case where we compare static con
Clemens Hammacher 2016/11/29 17:18:42 Done.
34 }
35
36 TEST(LoggingTest, CompareSignedMismatch) {
37 CHECK_SUCCEED(EQ, static_cast<int32_t>(14), static_cast<uint32_t>(14))
38 CHECK_FAIL(EQ, static_cast<int32_t>(14), static_cast<uint32_t>(15))
39 CHECK_SUCCEED(LT, static_cast<int32_t>(-1), static_cast<uint32_t>(0))
40 CHECK_SUCCEED(LT, static_cast<int32_t>(-1), static_cast<uint32_t>(-1))
41 CHECK_SUCCEED(LE, static_cast<int32_t>(-1), static_cast<uint32_t>(0))
42 CHECK_SUCCEED(LE, static_cast<int32_t>(55), static_cast<uint32_t>(55))
43 CHECK_SUCCEED(LT, static_cast<int32_t>(55), static_cast<uint32_t>(0x7fffff00))
44 CHECK_SUCCEED(LE, static_cast<int32_t>(55), static_cast<uint32_t>(0x7fffff00))
45 CHECK_SUCCEED(GE, static_cast<uint32_t>(0x7fffff00), static_cast<int32_t>(55))
46 CHECK_SUCCEED(GT, static_cast<uint32_t>(0x7fffff00), static_cast<int32_t>(55))
47 CHECK_SUCCEED(GT, static_cast<uint32_t>(-1), static_cast<int32_t>(-1))
48 CHECK_SUCCEED(GE, static_cast<uint32_t>(0), static_cast<int32_t>(-1))
49 CHECK_SUCCEED(LT, static_cast<int8_t>(-1), static_cast<uint32_t>(0))
50 CHECK_SUCCEED(GT, static_cast<uint64_t>(0x7f01010101010101), 0)
51 CHECK_SUCCEED(LE, static_cast<int64_t>(0xff01010101010101),
52 static_cast<uint8_t>(13))
23 } 53 }
24 54
25 } // namespace base 55 } // namespace base
26 } // namespace v8 56 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698