Expand PPBR compatibility fixtures
This commit is contained in:
@@ -24,25 +24,32 @@ std::array<std::byte, pp::assets::ppbr_header_size> ppbr_header(std::uint16_t ma
|
||||
|
||||
void parses_ppbr_header_and_legacy_version_tolerance(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto canonical_bytes = ppbr_header(0, 1);
|
||||
const auto canonical = pp::assets::parse_ppbr_header(canonical_bytes);
|
||||
struct Case {
|
||||
std::uint16_t major;
|
||||
std::uint16_t minor;
|
||||
bool accepted;
|
||||
};
|
||||
|
||||
PP_EXPECT(harness, canonical);
|
||||
PP_EXPECT(harness, canonical.value().major == 0U);
|
||||
PP_EXPECT(harness, canonical.value().minor == 1U);
|
||||
const std::array<Case, 6> cases {
|
||||
Case { 0U, 0U, true },
|
||||
Case { 0U, 1U, true },
|
||||
Case { 0U, 2U, true },
|
||||
Case { 1U, 1U, true },
|
||||
Case { 2U, 1U, true },
|
||||
Case { 1U, 2U, false },
|
||||
};
|
||||
|
||||
const auto tolerated_minor = pp::assets::parse_ppbr_header(ppbr_header(0, 2));
|
||||
const auto tolerated_major = pp::assets::parse_ppbr_header(ppbr_header(1, 1));
|
||||
const auto rejected_both = pp::assets::parse_ppbr_header(ppbr_header(1, 2));
|
||||
|
||||
PP_EXPECT(harness, tolerated_minor);
|
||||
PP_EXPECT(harness, tolerated_minor.value().major == 0U);
|
||||
PP_EXPECT(harness, tolerated_minor.value().minor == 2U);
|
||||
PP_EXPECT(harness, tolerated_major);
|
||||
PP_EXPECT(harness, tolerated_major.value().major == 1U);
|
||||
PP_EXPECT(harness, tolerated_major.value().minor == 1U);
|
||||
PP_EXPECT(harness, !rejected_both);
|
||||
PP_EXPECT(harness, rejected_both.status().code == pp::foundation::StatusCode::invalid_argument);
|
||||
for (const auto& item : cases) {
|
||||
const auto result = pp::assets::parse_ppbr_header(ppbr_header(item.major, item.minor));
|
||||
if (item.accepted) {
|
||||
PP_EXPECT(harness, result);
|
||||
PP_EXPECT(harness, result.value().major == item.major);
|
||||
PP_EXPECT(harness, result.value().minor == item.minor);
|
||||
} else {
|
||||
PP_EXPECT(harness, !result);
|
||||
PP_EXPECT(harness, result.status().code == pp::foundation::StatusCode::invalid_argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rejects_truncated_and_bad_magic_headers(pp::tests::Harness& harness)
|
||||
|
||||
Reference in New Issue
Block a user