| 26 | constexpr size_t SerializationBufferSize = 100 * 1024; |
| 27 | using namespace facebook::cachelib; |
| 28 | TEST(Serializer, InvalidSerialization) { |
| 29 | uint8_t buffer[SerializationBufferSize]; |
| 30 | uint8_t* begin = buffer; |
| 31 | uint8_t* end = buffer + SerializationBufferSize; |
| 32 | Serializer serializer(begin, end); |
| 33 | serialization::MemoryPoolManagerObject m; |
| 34 | serializer.serialize(m); |
| 35 | const size_t bytesUsed = |
| 36 | SerializationBufferSize - serializer.bytesRemaining(); |
| 37 | |
| 38 | // test serializing with smaller buffer than what is required and it must |
| 39 | // throw |
| 40 | { |
| 41 | const size_t smallSize = bytesUsed / 2; |
| 42 | ASSERT_LT(smallSize, bytesUsed); |
| 43 | uint8_t smallBuf[SerializationBufferSize]; |
| 44 | Serializer s2(&smallBuf[0], &smallBuf[smallSize - 1]); |
| 45 | ASSERT_THROW(s2.serialize(m), std::exception); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | TEST(Deserializer, InvaliDeSerialization) { |
| 50 | uint8_t buffer[SerializationBufferSize]; |
nothing calls this directly
no test coverage detected