1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

AK: Untangle TestSuite assertions a bit

This commit is contained in:
AnotherTest 2021-02-23 11:03:03 +03:30 committed by Andreas Kling
parent 531d72fdfd
commit 644d981b2b
Notes: sideshowbarker 2024-07-18 22:00:02 +09:00
3 changed files with 17 additions and 19 deletions

View file

@ -26,11 +26,9 @@
#pragma once #pragma once
#ifndef AK_TEST_SUITE #if defined(KERNEL)
# if defined(KERNEL)
# include <Kernel/Assertions.h> # include <Kernel/Assertions.h>
# else #else
# include <assert.h> # include <assert.h>
# ifndef __serenity__ # ifndef __serenity__
# define ASSERT assert # define ASSERT assert
@ -38,6 +36,4 @@
# define RELEASE_ASSERT assert # define RELEASE_ASSERT assert
# define TODO ASSERT_NOT_REACHED # define TODO ASSERT_NOT_REACHED
# endif # endif
# endif
#endif #endif

View file

@ -26,7 +26,7 @@
#pragma once #pragma once
#define AK_TEST_SUITE #include <AK/Assertions.h>
namespace AK { namespace AK {
@ -37,39 +37,40 @@ void warnln(const char* fmtstr, const Parameters&...);
using AK::warnln; using AK::warnln;
#undef ASSERT
#define ASSERT(x) \ #define ASSERT(x) \
do { \ do { \
if (!(x)) \ if (!(x)) \
::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: ASSERT({}) failed", __FILE__, __LINE__, #x); \ ::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: ASSERT({}) failed", __FILE__, __LINE__, #x); \
} while (false) } while (false)
#undef RELEASE_ASSERT
#define RELEASE_ASSERT(x) \ #define RELEASE_ASSERT(x) \
do { \ do { \
if (!(x)) \ if (!(x)) \
::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: RELEASE_ASSERT({}) failed", __FILE__, __LINE__, #x); \ ::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: RELEASE_ASSERT({}) failed", __FILE__, __LINE__, #x); \
} while (false) } while (false)
#undef ASSERT_NOT_REACHED
#define ASSERT_NOT_REACHED() \ #define ASSERT_NOT_REACHED() \
do { \ do { \
::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: ASSERT_NOT_REACHED() called", __FILE__, __LINE__); \ ::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: ASSERT_NOT_REACHED() called", __FILE__, __LINE__); \
::abort(); \ ::abort(); \
} while (false) } while (false)
#undef TODO
#define TODO() \ #define TODO() \
do { \ do { \
::AK::warnln(stderr, "\033[31;1mFAIL\033[0m: {}:{}: TODO() called", __FILE__, __LINE__); \ ::AK::warnln(stderr, "\033[31;1mFAIL\033[0m: {}:{}: TODO() called", __FILE__, __LINE__); \
::abort(); \ ::abort(); \
} while (false) } while (false)
#include <stdlib.h>
#include <AK/Format.h> #include <AK/Format.h>
#include <AK/Function.h> #include <AK/Function.h>
#include <AK/NonnullRefPtrVector.h> #include <AK/NonnullRefPtrVector.h>
#include <AK/String.h> #include <AK/String.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>
namespace AK { namespace AK {

View file

@ -24,9 +24,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <AK/StringUtils.h>
#include <AK/TestSuite.h> #include <AK/TestSuite.h>
#include <AK/StringUtils.h>
TEST_CASE(matches_null) TEST_CASE(matches_null)
{ {
EXPECT(AK::StringUtils::matches(StringView(), StringView())); EXPECT(AK::StringUtils::matches(StringView(), StringView()));