Skip to content

Commit

Permalink
#156: footprinting: add test for std::unordered_map (non-serializable)
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Nov 24, 2020
1 parent 9a842f6 commit 151b1c8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/test_footprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,28 @@ struct TestNoSerialize {
int i;
};

static_assert(
not SerializableTraits<TestNoSerialize>::is_traversable,
"TestNoSerialize has no serializer defined"
);

TEST_F(TestFootprinter, test_no_serialize) {
std::vector<TestNoSerialize> v(7);

EXPECT_EQ(
checkpoint::getMemoryFootprint(v),
sizeof(v) + v.capacity() * sizeof(TestNoSerialize)
);

std::unordered_map<int, TestNoSerialize> m;
m[1] = TestNoSerialize();
m[2] = TestNoSerialize();
m[3] = TestNoSerialize();
auto p = *m.begin();

EXPECT_EQ(
checkpoint::getMemoryFootprint(m),
sizeof(m) + m.size() * (sizeof(p) + sizeof(p.first) + sizeof(p.second))
);
}
}}} // end namespace checkpoint::tests::unit

0 comments on commit 151b1c8

Please sign in to comment.