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

Unified Diff: base/metrics/persistent_memory_allocator_unittest.cc

Issue 2387733002: Move memory management code into separate class for future reuse. (Closed)
Patch Set: object_free -> object_free_type Created 4 years, 2 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 | « base/metrics/persistent_memory_allocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/persistent_memory_allocator_unittest.cc
diff --git a/base/metrics/persistent_memory_allocator_unittest.cc b/base/metrics/persistent_memory_allocator_unittest.cc
index 6039d3e25129c17db1f77703bedcc7ceb7f5d32a..977d85fd4308eee1eda4a4ca7f70811b59f72a23 100644
--- a/base/metrics/persistent_memory_allocator_unittest.cc
+++ b/base/metrics/persistent_memory_allocator_unittest.cc
@@ -121,12 +121,15 @@ TEST_F(PersistentMemoryAllocatorTest, AllocateAndIterate) {
// Ensure that the test-object can be made iterable.
PersistentMemoryAllocator::Iterator iter1a(allocator_.get());
+ EXPECT_EQ(0U, iter1a.GetLast());
uint32_t type;
EXPECT_EQ(0U, iter1a.GetNext(&type));
allocator_->MakeIterable(block1);
EXPECT_EQ(block1, iter1a.GetNext(&type));
EXPECT_EQ(1U, type);
+ EXPECT_EQ(block1, iter1a.GetLast());
EXPECT_EQ(0U, iter1a.GetNext(&type));
+ EXPECT_EQ(block1, iter1a.GetLast());
// Create second test-object and ensure everything is good and it cannot
// be confused with test-object of another type.
@@ -146,6 +149,24 @@ TEST_F(PersistentMemoryAllocatorTest, AllocateAndIterate) {
allocator_->MakeIterable(block2);
EXPECT_EQ(block2, iter1a.GetNext(&type));
EXPECT_EQ(2U, type);
+ EXPECT_EQ(block2, iter1a.GetLast());
+ EXPECT_EQ(0U, iter1a.GetNext(&type));
+ EXPECT_EQ(block2, iter1a.GetLast());
+
+ // Check that the iterator can be reset to the beginning.
+ iter1a.Reset();
+ EXPECT_EQ(0U, iter1a.GetLast());
+ EXPECT_EQ(block1, iter1a.GetNext(&type));
+ EXPECT_EQ(block1, iter1a.GetLast());
+ EXPECT_EQ(block2, iter1a.GetNext(&type));
+ EXPECT_EQ(block2, iter1a.GetLast());
+ EXPECT_EQ(0U, iter1a.GetNext(&type));
+
+ // Check that the iterator can be reset to an arbitrary location.
+ iter1a.Reset(block1);
+ EXPECT_EQ(block1, iter1a.GetLast());
+ EXPECT_EQ(block2, iter1a.GetNext(&type));
+ EXPECT_EQ(block2, iter1a.GetLast());
EXPECT_EQ(0U, iter1a.GetNext(&type));
// Check that iteration can begin after an arbitrary location.
« no previous file with comments | « base/metrics/persistent_memory_allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698