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

Unified Diff: test/heap-unittests/heap-unittest.cc

Issue 490943002: Use size_t in GCIdleTimeHandler to fix undefined behaviour. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/heap-unittests/heap-unittest.cc
diff --git a/test/heap-unittests/heap-unittest.cc b/test/heap-unittests/heap-unittest.cc
index 220d8f2dffb7350579e9d489780eb58cc81f53d5..db331f91e068089b78c748a197547cd4864b22ac 100644
--- a/test/heap-unittests/heap-unittest.cc
+++ b/test/heap-unittests/heap-unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <climits>
+#include <limits>
#include "src/heap/gc-idle-time-handler.h"
@@ -12,33 +12,37 @@ namespace v8 {
namespace internal {
TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) {
- intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0);
- EXPECT_EQ(static_cast<intptr_t>(
- GCIdleTimeHandler::kInitialConservativeMarkingSpeed *
- GCIdleTimeHandler::kConservativeTimeRatio),
- step_size);
+ size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0);
+ EXPECT_EQ(
+ static_cast<size_t>(GCIdleTimeHandler::kInitialConservativeMarkingSpeed *
+ GCIdleTimeHandler::kConservativeTimeRatio),
+ step_size);
}
TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeNonZero) {
- intptr_t marking_speed_in_bytes_per_millisecond = 100;
- intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
+ size_t marking_speed_in_bytes_per_millisecond = 100;
+ size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
1, marking_speed_in_bytes_per_millisecond);
- EXPECT_EQ(static_cast<intptr_t>(marking_speed_in_bytes_per_millisecond *
- GCIdleTimeHandler::kConservativeTimeRatio),
+ EXPECT_EQ(static_cast<size_t>(marking_speed_in_bytes_per_millisecond *
+ GCIdleTimeHandler::kConservativeTimeRatio),
step_size);
}
TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow1) {
- intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(10, INT_MAX);
- EXPECT_EQ(INT_MAX, step_size);
+ size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
+ 10, std::numeric_limits<size_t>::max());
+ EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize),
+ step_size);
}
TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow2) {
- intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(INT_MAX, 10);
- EXPECT_EQ(INT_MAX, step_size);
+ size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
+ std::numeric_limits<size_t>::max(), 10);
+ EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize),
+ step_size);
}
} // namespace internal
« no previous file with comments | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698