mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 09:58:50 +08:00
Add test
This commit is contained in:
parent
027029cc9b
commit
770ef6e726
@ -488,6 +488,10 @@ TEST_CASE("/flow/FlatBuffers/Standalone") {
|
||||
// Meant to be run with valgrind or asan, to catch heap buffer overflows
|
||||
TEST_CASE("/flow/FlatBuffers/Void") {
|
||||
Standalone<StringRef> msg = ObjectWriter::toValue(Void(), Unversioned());
|
||||
// Manually verified to be a valid flatbuffers message. This is technically brittle since there are other valid
|
||||
// encodings of this message, but our implementation is unlikely to change.
|
||||
ASSERT(msg == LiteralStringRef("\x14\x00\x00\x00J\xad\x1e\x00\x00\x00\x04\x00\x04\x00\x06\x00\x08\x00\x04\x00\x06"
|
||||
"\x00\x00\x00\x04\x00\x00\x00\x12\x00\x00\x00"));
|
||||
auto buffer = std::make_unique<uint8_t[]>(msg.size()); // Make a heap allocation of precisely the right size, so
|
||||
// that asan or valgrind will catch any overflows
|
||||
memcpy(buffer.get(), msg.begin(), msg.size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user