Skip to content

Commit

Permalink
Add embedded container tests for read_valid_eof1_header()
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Sep 14, 2023
1 parent f899912 commit 64374ea
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions test/unittests/eof_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ TEST(eof, read_valid_eof1_header)
uint16_t types_size;
uint16_t data_size;
std::vector<uint16_t> code_sizes;
std::vector<uint16_t> container_sizes;
};
std::string nops_255;
for (int i = 0; i < 255; ++i)
Expand All @@ -42,20 +43,34 @@ TEST(eof, read_valid_eof1_header)
section_size_1_256 += "0001";

const TestCase test_cases[] = {
{"EF00 01 010004 0200010001 040000 00 00000000 00", 4, 0, {1}},
{"EF00 01 010004 0200010006 040000 00 00000002 600160005500", 4, 0, {6}},
{"EF00 01 010004 0200010001 040001 00 00000000 00 AA", 4, 1, {1}},
{"EF00 01 010004 0200010006 040004 00 00000002 600160005500 AABBCCDD", 4, 4, {6}},
{"EF00 01 010004 0200010001 040000 00 00000000 00", 4, 0, {1}, {}},
{"EF00 01 010004 0200010006 040000 00 00000002 600160005500", 4, 0, {6}, {}},
{"EF00 01 010004 0200010001 040001 00 00000000 00 AA", 4, 1, {1}, {}},
{"EF00 01 010004 0200010006 040004 00 00000002 600160005500 AABBCCDD", 4, 4, {6}, {}},
{"EF00 01 01000C 020003000100020003 040000 00 000000000000000000000000 00 5B00 5B5B00", 12,
0, {1, 2, 3}},
0, {1, 2, 3}, {}},
{"EF00 01 01000C 020003000100020003 040004 00 000000000000000000000000 00 5B00 5B5B00 "
"FFFFFFFF",
12, 4, {1, 2, 3}},
12, 4, {1, 2, 3}, {}},
{"EF00 01 010004 0200010100 041000 00 00000000" + nops_255 + "00" + std::string(8192, 'F'),
4, 4096, {256}},
4, 4096, {256}, {}},
{"EF00 01 010400 020100" + section_size_1_256 + " 041000 00 " +
std::string(4 * 256 * 2, '0') + std::string(512, '0') + std::string(8192, 'F'),
4 * 256, 4096, std::vector<uint16_t>(256, 1)},
4 * 256, 4096, std::vector<uint16_t>(256, 1), {}},
{"EF00 01 010004 0200010001 0300010001 040000 00 00000000 00 00", 4, 0, {1}, {1}},
{"EF00 01 010004 0200010001 0300010002 040003 00 00000000 00 0000 000000", 4, 3, {1}, {2}},
{"EF00 01 010004 0200010001 030003000100020003 040000 00 00000000 00 aa bbbb cccccc", 4, 0,
{1}, {1, 2, 3}},
{"EF00 01 010004 0200010001 030003000100020003 040003 00 00000000 00 aa bbbb cccccc ddeeff",
4, 3, {1}, {1, 2, 3}},
{"EF00 01 01000C 020003000100010001 030003000100020003 040003 00 000000000000000000000000 "
"00 00 00 aa bbbb cccccc ddeeff",
12, 3, {1, 1, 1}, {1, 2, 3}},
{"EF00 01 010004 0200010001 0300010100 040000 00 00000000 00 " + std::string(512, 'F'), 4,
0, {1}, {256}},
{"EF00 01 010004 0200010001 030100" + section_size_1_256 + "040000 00 00000000 00 " +
std::string(512, 'F'),
4, 0, {1}, std::vector<uint16_t>(256, 1)},
};

for (const auto& test_case : test_cases)
Expand All @@ -67,5 +82,6 @@ TEST(eof, read_valid_eof1_header)
EXPECT_EQ(header.code_sizes, test_case.code_sizes) << test_case.code;
EXPECT_EQ(header.data_size, test_case.data_size) << test_case.code;
EXPECT_EQ(header.types.size() * 4, test_case.types_size) << test_case.code;
EXPECT_EQ(header.container_sizes, test_case.container_sizes) << test_case.code;
}
}

0 comments on commit 64374ea

Please sign in to comment.