mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 18:32:18 +08:00
Add unit test
This commit is contained in:
parent
a3f67aa704
commit
7119b46eb2
@ -485,4 +485,16 @@ TEST_CASE("/flow/FlatBuffers/Standalone") {
|
|||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
auto buffer = std::make_unique<uint8_t[]>(msg.size()); // Make a heap allocation of precisely the right size, to
|
||||||
|
// that asan or valgrind will catch any overflows
|
||||||
|
memcpy(buffer.get(), msg.begin(), msg.size());
|
||||||
|
ObjectReader rd(buffer.get(), Unversioned());
|
||||||
|
Void x;
|
||||||
|
rd.deserialize(x);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace unit_tests
|
} // namespace unit_tests
|
||||||
|
Loading…
x
Reference in New Issue
Block a user