PEL: Refactor the test data factory
This commit has no functional changes, it just does some things
to make the PEL data creator for testcases, pelDataFactory(), be
more manageable:
- Change to return a plain vector instead of a unique_ptr<vector>.
- Keeps the data for each section in separate vectors and then
either returns those as-is or combines them into a PEL.
- Change the TestPelType enum to TestPELType to match the style guide.
- Have pelDataFactory provide the SRC section instead of srcDataFactory.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I4770aa6a8169e89b6b8f685a9994d845c9e93cfe
diff --git a/test/openpower-pels/generic_section_test.cpp b/test/openpower-pels/generic_section_test.cpp
index 9fb6d9a..7cb9949 100644
--- a/test/openpower-pels/generic_section_test.cpp
+++ b/test/openpower-pels/generic_section_test.cpp
@@ -8,13 +8,13 @@
TEST(GenericSectionTest, UnflattenFlattenTest)
{
// Use the private header data
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
- Stream stream(*data);
+ Stream stream(data);
Generic section(stream);
EXPECT_EQ(section.header().id, 0x5048);
- EXPECT_EQ(section.header().size, data->size());
+ EXPECT_EQ(section.header().size, data.size());
EXPECT_EQ(section.header().version, 0x01);
EXPECT_EQ(section.header().subType, 0x02);
EXPECT_EQ(section.header().componentID, 0x0304);
@@ -22,11 +22,11 @@
const auto& sectionData = section.data();
// The data itself starts after the header
- EXPECT_EQ(sectionData.size(), data->size() - 8);
+ EXPECT_EQ(sectionData.size(), data.size() - 8);
for (size_t i = 0; i < sectionData.size(); i++)
{
- EXPECT_EQ(sectionData[i], (*data)[i + 8]);
+ EXPECT_EQ(sectionData[i], (data)[i + 8]);
}
// Now flatten
@@ -34,16 +34,16 @@
Stream newStream(newData);
section.flatten(newStream);
- EXPECT_EQ(*data, newData);
+ EXPECT_EQ(data, newData);
}
TEST(GenericSectionTest, BadDataTest)
{
// Use the private header data to start with
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
- data->resize(4);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
+ data.resize(4);
- Stream stream(*data);
+ Stream stream(data);
Generic section(stream);
ASSERT_FALSE(section.valid());
}