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

Unified Diff: base/sys_info_unittest.cc

Issue 2765793002: Fix integer overflow in unittest. (Closed)
Patch Set: Created 3 years, 9 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_unittest.cc
diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc
index 3793ff33192f9f331e8f20cac9649af28a25378b..e80884b9b20ffb3b050cab7cfef093500a7cadb9 100644
--- a/base/sys_info_unittest.cc
+++ b/base/sys_info_unittest.cc
@@ -43,8 +43,8 @@ TEST_F(SysInfoTest, AmountOfAvailablePhysicalMemory) {
EXPECT_LT(info.available, info.total);
const int64_t amount = SysInfo::AmountOfAvailablePhysicalMemory(info);
// We aren't actually testing that it's correct, just that it's sane.
- EXPECT_GT(amount, info.free * 1024);
- EXPECT_LT(amount, info.available * 1024);
+ EXPECT_GT(amount, static_cast<int64_t>(info.free) * 1024);
+ EXPECT_LT(amount / 1024, info.available);
// Simulate as if there is no MemAvailable.
info.available = 0;
}
@@ -52,8 +52,8 @@ TEST_F(SysInfoTest, AmountOfAvailablePhysicalMemory) {
// There is no MemAvailable. Check the fallback logic.
const int64_t amount = SysInfo::AmountOfAvailablePhysicalMemory(info);
// We aren't actually testing that it's correct, just that it's sane.
- EXPECT_GT(amount, info.free * 1024);
- EXPECT_LT(amount, info.total * 1024);
+ EXPECT_GT(amount, static_cast<int64_t>(info.free) * 1024);
+ EXPECT_LT(amount / 1024, info.total);
}
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698