Add test helper macros. (#465)

- Refactor the existing SNMALLOC_ASSERT and SNMALLOC_CHECK.  These now
   use the FatalErrorBuilder to format the output if a format string is
   provided.
 - Extend the FatalErrorBuilder to print decimal integers for signed
   values.
 - Rename FatalErrorBuilder to MessageBuilder.
 - Rewrite the macros used in the jemalloc tests to use
   FatalErrorBuilder and move them into a header.
 - Refactor some of the tests to use the new macros.
This commit is contained in:
David Chisnall
2022-02-25 15:57:28 +00:00
committed by GitHub
parent 93efbb4807
commit 95bd974fb0
7 changed files with 234 additions and 147 deletions

View File

@@ -161,10 +161,10 @@ namespace snmalloc
*
* These types should be sufficient for allocator-related error messages.
*/
template<size_t BufferSize = 1024, typename... Args>
template<size_t BufferSize, typename... Args>
[[noreturn]] inline void report_fatal_error(Args... args)
{
FatalErrorBuilder<BufferSize> msg{std::forward<Args>(args)...};
MessageBuilder<BufferSize> msg{std::forward<Args>(args)...};
Pal::error(msg.get_message());
}