blob: 2d5827cb6bae1c1b5633c2153915dc1247ea941d [file] [log] [blame]
Matt Spinler1b5c72b2019-07-10 10:32:06 -05001
2#include "extensions/openpower-pels/section_header.hpp"
3
4#include <gtest/gtest.h>
5
6using namespace openpower::pels;
7
8TEST(SectionHeaderTest, SizeTest)
9{
10 EXPECT_EQ(SectionHeader::flattenedSize(), 8);
11}
12
13TEST(SectionHeaderTest, UnflattenTest)
14{
15 std::vector<uint8_t> data{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
16 Stream reader{data};
17 SectionHeader header;
18
19 reader >> header;
20
21 EXPECT_EQ(header.id, 0x1122);
22 EXPECT_EQ(header.size, 0x3344);
23 EXPECT_EQ(header.version, 0x55);
24 EXPECT_EQ(header.subType, 0x66);
25 EXPECT_EQ(header.componentID, 0x7788);
26}
27
28TEST(SectionHeaderTest, FlattenTest)
29{
30 SectionHeader header{0xAABB, 0xCCDD, 0xEE, 0xFF, 0xA0A0};
31
32 std::vector<uint8_t> data;
33 Stream writer{data};
34
35 writer << header;
36
37 std::vector<uint8_t> expected{0xAA, 0xBB, 0xCC, 0xDD,
38 0xEE, 0xFF, 0xA0, 0xA0};
39 EXPECT_EQ(data, expected);
40}