srctree

Robin Linden parent a8639a20 02ac8630
etest: Add failure tests for uncaught exceptions

filename was Deleted added: 38, removed: 2, total 36
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "etest/etest2.h"
 
int main() {
auto s = etest::Suite{};
s.add_test("uncaught exception", []([[maybe_unused]] auto &a) {
#if defined(__EXCEPTIONS) || defined(_MSC_VER)
throw std::exception{};
#else
a.require(false);
#endif
});
return s.run();
}
 
filename was Deleted added: 38, removed: 2, total 36
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "etest/etest2.h"
 
int main() {
auto s = etest::Suite{};
// We want e.g. exceptions not derived from std::exception to be registered
// as failures too.
s.add_test("uncaught number", []([[maybe_unused]] auto &a) {
#if defined(__EXCEPTIONS) || defined(_MSC_VER)
throw 42;
#else
a.require(false);
#endif
});
return s.run();
}