2021-12-14 23:37:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibTest/TestCase.h>
|
|
|
|
|
2021-12-14 16:44:43 +00:00
|
|
|
#undef NDEBUG
|
2021-12-14 23:37:40 +00:00
|
|
|
#include <assert.h>
|
2021-12-17 17:12:47 +00:00
|
|
|
#include <signal.h>
|
2021-12-14 23:37:40 +00:00
|
|
|
|
|
|
|
TEST_CASE(assert)
|
|
|
|
{
|
|
|
|
EXPECT_CRASH("This should assert", [] {
|
|
|
|
assert(!"This should assert");
|
|
|
|
return Test::Crash::Failure::DidNotCrash;
|
|
|
|
});
|
2021-12-17 17:12:47 +00:00
|
|
|
EXPECT_CRASH_WITH_SIGNAL("This should assert with SIGABRT signal", SIGABRT, [] {
|
|
|
|
assert(!"This should assert");
|
|
|
|
return Test::Crash::Failure::DidNotCrash;
|
|
|
|
});
|
2021-12-14 23:37:40 +00:00
|
|
|
}
|
2021-12-14 16:44:43 +00:00
|
|
|
|
|
|
|
#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;
|
|
|
|
});
|
|
|
|
}
|