mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 09:58:50 +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();
|
||||
}
|
||||
|
||||
// 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user