Commit 47c013b0 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2206] Make a common function out of duplicate code

parent 3d68f767
......@@ -54,22 +54,25 @@ TEST_F(ZoneTableSegmentTest, create) {
EXPECT_NE(static_cast<void*>(NULL), segment_);
}
TEST_F(ZoneTableSegmentTest, getHeader) {
ZoneTableHeader& header = segment_->getHeader();
// Helper function to check const and non-const methods.
template <typename TS, typename TH>
void
testGetHeader(ZoneTableSegment* segment) {
TH& header = static_cast<TS*>(segment)->getHeader();
// The zone table is unset.
ZoneTable* table = header.getTable();
const ZoneTable* table = header.getTable();
EXPECT_EQ(static_cast<void*>(NULL), table);
}
TEST_F(ZoneTableSegmentTest, getHeaderConst) {
// Test const methods
const ZoneTableHeader& header =
static_cast<const ZoneTableSegment*>(segment_)->getHeader();
TEST_F(ZoneTableSegmentTest, getHeader) {
// non-const version.
testGetHeader<ZoneTableSegment, ZoneTableHeader>(segment_);
}
// The zone table is unset.
const ZoneTable* table = header.getTable();
EXPECT_EQ(static_cast<void*>(NULL), table);
TEST_F(ZoneTableSegmentTest, getHeaderConst) {
// const version.
testGetHeader<const ZoneTableSegment, const ZoneTableHeader>(segment_);
}
TEST_F(ZoneTableSegmentTest, getMemorySegment) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment