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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-text.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/base/logging-unittest.cc
diff --git a/test/unittests/base/logging-unittest.cc b/test/unittests/base/logging-unittest.cc
index d79e59ee06e54504e00508f3cfdb6527fd52fa4c..39e5a11824bc7dde3d85cf21a844dac2c8d4dc24 100644
--- a/test/unittests/base/logging-unittest.cc
+++ b/test/unittests/base/logging-unittest.cc
@@ -9,17 +9,47 @@ namespace v8 {
namespace base {
namespace {
-template <typename Lhs, typename Rhs>
-std::string *CallCheckEQ(Lhs lhs, Rhs rhs, const char *msg) {
- return CheckEQImpl<Lhs, Rhs>(lhs, rhs, msg);
-}
+
+#define CHECK_SUCCEED(NAME, lhs, rhs) \
+ { \
+ std::string* error_message = \
+ Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \
+ EXPECT_EQ(nullptr, error_message); \
+ }
+
+#define CHECK_FAIL(NAME, lhs, rhs) \
+ { \
+ std::string* error_message = \
+ Check##NAME##Impl<decltype(lhs), decltype(rhs)>((lhs), (rhs), ""); \
+ EXPECT_NE(nullptr, error_message); \
+ }
+
} // namespace
TEST(LoggingTest, CheckEQImpl) {
- EXPECT_EQ(nullptr, CallCheckEQ(0.0, 0.0, ""));
- EXPECT_EQ(nullptr, CallCheckEQ(0.0, -0.0, ""));
- EXPECT_EQ(nullptr, CallCheckEQ(-0.0, 0.0, ""));
- EXPECT_EQ(nullptr, CallCheckEQ(-0.0, -0.0, ""));
+ CHECK_SUCCEED(EQ, 0.0, 0.0)
+ CHECK_SUCCEED(EQ, 0.0, -0.0)
+ CHECK_SUCCEED(EQ, -0.0, 0.0)
+ 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.
+}
+
+TEST(LoggingTest, CompareSignedMismatch) {
+ CHECK_SUCCEED(EQ, static_cast<int32_t>(14), static_cast<uint32_t>(14))
+ CHECK_FAIL(EQ, static_cast<int32_t>(14), static_cast<uint32_t>(15))
+ CHECK_SUCCEED(LT, static_cast<int32_t>(-1), static_cast<uint32_t>(0))
+ CHECK_SUCCEED(LT, static_cast<int32_t>(-1), static_cast<uint32_t>(-1))
+ CHECK_SUCCEED(LE, static_cast<int32_t>(-1), static_cast<uint32_t>(0))
+ CHECK_SUCCEED(LE, static_cast<int32_t>(55), static_cast<uint32_t>(55))
+ CHECK_SUCCEED(LT, static_cast<int32_t>(55), static_cast<uint32_t>(0x7fffff00))
+ CHECK_SUCCEED(LE, static_cast<int32_t>(55), static_cast<uint32_t>(0x7fffff00))
+ CHECK_SUCCEED(GE, static_cast<uint32_t>(0x7fffff00), static_cast<int32_t>(55))
+ CHECK_SUCCEED(GT, static_cast<uint32_t>(0x7fffff00), static_cast<int32_t>(55))
+ CHECK_SUCCEED(GT, static_cast<uint32_t>(-1), static_cast<int32_t>(-1))
+ CHECK_SUCCEED(GE, static_cast<uint32_t>(0), static_cast<int32_t>(-1))
+ CHECK_SUCCEED(LT, static_cast<int8_t>(-1), static_cast<uint32_t>(0))
+ CHECK_SUCCEED(GT, static_cast<uint64_t>(0x7f01010101010101), 0)
+ CHECK_SUCCEED(LE, static_cast<int64_t>(0xff01010101010101),
+ static_cast<uint8_t>(13))
}
} // namespace base
« 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