From c2be38e50f7c91960bd899dc7f2b6a5028a38bf6 Mon Sep 17 00:00:00 2001 From: asynts Date: Sat, 22 Aug 2020 16:24:37 +0200 Subject: [PATCH] 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 } --- AK/TestSuite.h | 14 ++++++++++---- 1 file 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