mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +00:00
682f89d5bc
ISO C requires in section 7.2: The assert macro is redefined according to the current state of NDEBUG each time that <assert.h> is included. Also add tests for `assert` multiple inclusion accordingly.
45 lines
965 B
C++
45 lines
965 B
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibTest/TestCase.h>
|
|
|
|
#undef NDEBUG
|
|
#include <assert.h>
|
|
#include <signal.h>
|
|
|
|
TEST_CASE(assert)
|
|
{
|
|
EXPECT_CRASH("This should assert", [] {
|
|
assert(!"This should assert");
|
|
return Test::Crash::Failure::DidNotCrash;
|
|
});
|
|
EXPECT_CRASH_WITH_SIGNAL("This should assert with SIGABRT signal", SIGABRT, [] {
|
|
assert(!"This should assert");
|
|
return Test::Crash::Failure::DidNotCrash;
|
|
});
|
|
}
|
|
|
|
#define NDEBUG
|
|
#include <assert.h>
|
|
|
|
TEST_CASE(assert_reinclude)
|
|
{
|
|
EXPECT_NO_CRASH("This should not assert", [] {
|
|
assert(!"This should not assert");
|
|
return Test::Crash::Failure::DidNotCrash;
|
|
});
|
|
}
|
|
|
|
#undef NDEBUG
|
|
#include <assert.h>
|
|
|
|
TEST_CASE(assert_rereinclude)
|
|
{
|
|
EXPECT_CRASH("This should assert", [] {
|
|
assert(!"This should assert");
|
|
return Test::Crash::Failure::DidNotCrash;
|
|
});
|
|
}
|