Harden binary stream overlapping writes
This commit is contained in:
@@ -87,6 +87,26 @@ void boundary_reads_are_consistent(pp::tests::Harness& h)
|
||||
}
|
||||
}
|
||||
|
||||
void appends_overlapping_source_bytes_deterministically(pp::tests::Harness& h)
|
||||
{
|
||||
std::vector<std::byte> bytes {
|
||||
std::byte { 0x10 },
|
||||
std::byte { 0x20 },
|
||||
std::byte { 0x30 },
|
||||
};
|
||||
ByteWriter writer(bytes);
|
||||
|
||||
const auto status = writer.write_bytes(std::span<const std::byte>(bytes.data() + 1, 2));
|
||||
|
||||
PP_EXPECT(h, status.ok());
|
||||
PP_EXPECT(h, writer.size() == 5U);
|
||||
PP_EXPECT(h, bytes[0] == std::byte { 0x10 });
|
||||
PP_EXPECT(h, bytes[1] == std::byte { 0x20 });
|
||||
PP_EXPECT(h, bytes[2] == std::byte { 0x30 });
|
||||
PP_EXPECT(h, bytes[3] == std::byte { 0x20 });
|
||||
PP_EXPECT(h, bytes[4] == std::byte { 0x30 });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -96,5 +116,6 @@ int main()
|
||||
harness.run("rejects_overread_without_moving_cursor", rejects_overread_without_moving_cursor);
|
||||
harness.run("rejects_out_of_range_seek", rejects_out_of_range_seek);
|
||||
harness.run("boundary_reads_are_consistent", boundary_reads_are_consistent);
|
||||
harness.run("appends_overlapping_source_bytes_deterministically", appends_overlapping_source_bytes_deterministically);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user