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,18 +26,14 @@
#pragma once
#ifndef AK_TEST_SUITE
# if defined(KERNEL)
# include <Kernel/Assertions.h>
# else
# include <assert.h>
# ifndef __serenity__
# define ASSERT assert
# define ASSERT_NOT_REACHED() assert(false)
# define RELEASE_ASSERT assert
# define TODO ASSERT_NOT_REACHED
# endif
#if defined(KERNEL)
# include <Kernel/Assertions.h>
#else
# include <assert.h>
# ifndef __serenity__
# define ASSERT assert
# define ASSERT_NOT_REACHED() assert(false)
# define RELEASE_ASSERT assert
# define TODO ASSERT_NOT_REACHED
# endif
#endif

View File

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

View File

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