diff options
author | Michel Hermier <michel.hermier@gmail.com> | 2021-12-15 00:47:43 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-12-19 14:22:06 -0800 |
commit | 7a44c11378bf4920728f117a586dfa9c589992aa (patch) | |
tree | 19f874ea0e7f033301452c55ce3f890e9e9019c4 /Userland/Libraries | |
parent | 4c6e826c055e23493a8b3d72f5f9e5af7a5432ad (diff) | |
download | serenity-7a44c11378bf4920728f117a586dfa9c589992aa.zip |
LibTest: Add `EXPECT_NO_CRASH`
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibTest/CrashTest.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibTest/Macros.h | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibTest/CrashTest.cpp b/Userland/Libraries/LibTest/CrashTest.cpp index ac8433d9be..419867342a 100644 --- a/Userland/Libraries/LibTest/CrashTest.cpp +++ b/Userland/Libraries/LibTest/CrashTest.cpp @@ -64,6 +64,8 @@ bool Crash::do_report(Report report) bool pass = false; if (m_crash_signal == ANY_SIGNAL) { pass = report.has<int>(); + } else if (m_crash_signal == 0) { + pass = report.has<Failure>() && report.get<Failure>() == Failure::DidNotCrash; } else if (m_crash_signal > 0) { pass = report.has<int>() && report.get<int>() == m_crash_signal; } else { diff --git a/Userland/Libraries/LibTest/Macros.h b/Userland/Libraries/LibTest/Macros.h index d0dca516aa..6f32e0ae13 100644 --- a/Userland/Libraries/LibTest/Macros.h +++ b/Userland/Libraries/LibTest/Macros.h @@ -134,3 +134,10 @@ void current_test_case_did_fail(); if (!crash.run()) \ ::Test::current_test_case_did_fail(); \ } while (false) + +#define EXPECT_NO_CRASH(test_message, test_func) \ + do { \ + Test::Crash crash(test_message, test_func, 0); \ + if (!crash.run()) \ + ::Test::current_test_case_did_fail(); \ + } while (false) |