mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
TestSuite: Hijack the ASSERT macros during unit tests.
Instead of aborting the program when we hit an assertion, just print a message and keep going. This allows us to write tests that provoke assertions on purpose.
This commit is contained in:
parent
31793b8f3a
commit
6560116b67
Notes:
sideshowbarker
2024-07-19 12:56:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6560116b67c
7 changed files with 22 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef AK_TEST_SUITE
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Assertions.h>
|
||||
#else
|
||||
|
@ -11,6 +13,8 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace AK {
|
||||
|
||||
inline void not_implemented() { ASSERT(false); }
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#define AK_TEST_SUITE
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define ASSERT(x) \
|
||||
if (!(x)) { \
|
||||
fprintf(stderr, "\033[33;1mASSERT\033[0m: " #x "\n"); \
|
||||
}
|
||||
|
||||
#define ASSERT_NOT_REACHED() fprintf(stderr, "\033[31;1mASSERT_NOT_REACHED\033[0m\n");
|
||||
#define RELEASE_ASSERT ASSERT
|
||||
|
||||
#include "AKString.h"
|
||||
#include "Function.h"
|
||||
#include "NonnullRefPtrVector.h"
|
||||
#include <chrono>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/JsonArray.h>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Queue.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
|
||||
TEST_CASE(construct_empty)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/TestSuite.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
TEST_CASE(construct)
|
||||
|
|
Loading…
Reference in a new issue