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

Unified Diff: test/unittests/zone/zone-chunk-list-unittest.cc

Issue 2468183004: Used ZoneChunkList in deoptimizer (Closed)
Patch Set: Added unittests to ensure correct copyto 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/zone/zone-chunk-list.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/zone/zone-chunk-list-unittest.cc
diff --git a/test/unittests/zone/zone-chunk-list-unittest.cc b/test/unittests/zone/zone-chunk-list-unittest.cc
index 13ff2cf04b43b0e518dedf08788e77084aeb672d..11790bb072782fcbee0cd9813834a9949fdce75b 100644
--- a/test/unittests/zone/zone-chunk-list-unittest.cc
+++ b/test/unittests/zone/zone-chunk-list-unittest.cc
@@ -140,5 +140,68 @@ TEST(ZoneChunkList, FindTest) {
EXPECT_EQ(*zone_chunk_list.Find(index), 42);
}
+TEST(ZoneChunkList, CopyToTest) {
+ AccountingAllocator allocator;
+ Zone zone(&allocator, ZONE_NAME);
+
+ ZoneChunkList<uintptr_t> zone_chunk_list(&zone);
+
+ for (size_t i = 0; i < kItemCount; ++i) {
+ zone_chunk_list.push_back(static_cast<uintptr_t>(i));
+ }
+
+ uintptr_t* array = zone.NewArray<uintptr_t>(kItemCount);
+
+ zone_chunk_list.CopyTo(array);
+
+ for (size_t i = 0; i < kItemCount; ++i) {
+ EXPECT_EQ(array[i], static_cast<uintptr_t>(i));
+ }
+}
+
+TEST(ZoneChunkList, SmallCopyToTest) {
+ AccountingAllocator allocator;
+ Zone zone(&allocator, ZONE_NAME);
+
+ ZoneChunkList<uint8_t> zone_chunk_list(&zone);
+
+ for (size_t i = 0; i < kItemCount; ++i) {
+ zone_chunk_list.push_back(static_cast<uint8_t>(i & 0xFF));
+ }
+
+ uint8_t* array = zone.NewArray<uint8_t>(kItemCount);
+
+ zone_chunk_list.CopyTo(array);
+
+ for (size_t i = 0; i < kItemCount; ++i) {
+ EXPECT_EQ(array[i], static_cast<uint8_t>(i & 0xFF));
+ }
+}
+
+struct Fubar {
+ size_t a_;
+ size_t b_;
+};
+
+TEST(ZoneChunkList, BigCopyToTest) {
+ AccountingAllocator allocator;
+ Zone zone(&allocator, ZONE_NAME);
+
+ ZoneChunkList<Fubar> zone_chunk_list(&zone);
+
+ for (size_t i = 0; i < kItemCount; ++i) {
+ zone_chunk_list.push_back({i, i + 5});
+ }
+
+ Fubar* array = zone.NewArray<Fubar>(kItemCount);
+
+ zone_chunk_list.CopyTo(array);
+
+ for (size_t i = 0; i < kItemCount; ++i) {
+ EXPECT_EQ(array[i].a_, i);
+ EXPECT_EQ(array[i].b_, i + 5);
+ }
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/zone/zone-chunk-list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698