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 |