summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-08-22 16:24:37 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-22 20:52:19 +0200
commitc2be38e50f7c91960bd899dc7f2b6a5028a38bf6 (patch)
tree341d4e6687bd9523086fb799b82a0211da1acb7a /AK
parent103f659ef66dc608f88f5d9547dd702a6c9e6554 (diff)
downloadserenity-c2be38e50f7c91960bd899dc7f2b6a5028a38bf6.zip
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 }
Diffstat (limited to 'AK')
-rw-r--r--AK/TestSuite.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/AK/TestSuite.h b/AK/TestSuite.h
index b1769ba117..6098c3b42f 100644
--- a/AK/TestSuite.h
+++ b/AK/TestSuite.h
@@ -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>