mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
AK: TestSuite: Terminate when ASSERT_NOT_REACHED is called.
Previously, it would just print something with 'FAIL' to stderr which would be picked up by CTest. However, some code assumes that ASSERT_NOT_REACHED() doesn't return, for example: bool foo(int value) { switch(value) { case 0: return true; case 1: return false; default: ASSERT_NOT_REACHED(); } // warning: control reaches end of non-void function }
This commit is contained in:
parent
103f659ef6
commit
c2be38e50f
1 changed files with 10 additions and 4 deletions
|
@ -40,11 +40,17 @@
|
|||
fprintf(stderr, "\033[31;1mFAIL\033[0m: %s:%d: RELEASE_ASSERT(%s) failed\n", __FILE__, __LINE__, #x); \
|
||||
}
|
||||
|
||||
#define ASSERT_NOT_REACHED() \
|
||||
fprintf(stderr, "\033[31;1mFAIL\033[0m: %s:%d: ASSERT_NOT_REACHED() called\n", __FILE__, __LINE__);
|
||||
#define ASSERT_NOT_REACHED() \
|
||||
{ \
|
||||
fprintf(stderr, "\033[31;1mFAIL\033[0m: %s:%d: ASSERT_NOT_REACHED() called\n", __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
#define TODO \
|
||||
fprintf(stderr, "\033[31;1mFAIL\033[0m: %s:%d: TODO() called\n", __FILE__, __LINE__);
|
||||
#define TODO() \
|
||||
{ \
|
||||
fprintf(stderr, "\033[31;1mFAIL\033[0m: %s:%d: TODO() called\n", __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue