From 181f759dc93fcfa11f8d5692624bf1f597d3f404 Mon Sep 17 00:00:00 2001 From: Michel Hermier Date: Fri, 17 Dec 2021 17:58:55 +0100 Subject: [PATCH] Tests: Add test for `abort` --- Tests/LibC/CMakeLists.txt | 1 + Tests/LibC/TestAbort.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 Tests/LibC/TestAbort.cpp diff --git a/Tests/LibC/CMakeLists.txt b/Tests/LibC/CMakeLists.txt index 9976d2ebab..312188b896 100644 --- a/Tests/LibC/CMakeLists.txt +++ b/Tests/LibC/CMakeLists.txt @@ -1,4 +1,5 @@ set(TEST_SOURCES + TestAbort.cpp TestIo.cpp TestLibCExec.cpp TestLibCDirEnt.cpp diff --git a/Tests/LibC/TestAbort.cpp b/Tests/LibC/TestAbort.cpp new file mode 100644 index 0000000000..2572fc3c67 --- /dev/null +++ b/Tests/LibC/TestAbort.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +#include // FIXME: Remove when `_abort` is moved to +#include + +TEST_CASE(_abort) +{ + EXPECT_CRASH("This should _abort", [] { + _abort(); + return Test::Crash::Failure::DidNotCrash; + }); +} + +TEST_CASE(abort) +{ + EXPECT_CRASH("This should abort", [] { + abort(); + return Test::Crash::Failure::DidNotCrash; + }); +}