summaryrefslogtreecommitdiffstats
path: root/tests/no_exceptions.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/no_exceptions.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/no_exceptions.cpp b/tests/no_exceptions.cpp
new file mode 100644
index 0000000..ee270d6
--- /dev/null
+++ b/tests/no_exceptions.cpp
@@ -0,0 +1,22 @@
+#include <frozen/unordered_map.h>
+
+#include <csignal>
+#include <cstdlib>
+
+// https://discourse.cmake.org/t/tests-that-are-meant-to-abort/537/3
+// This is a hack to implement death tests in CTest.
+extern "C" void error_test_handle_abort(int) { std::_Exit(EXIT_FAILURE); }
+
+struct test_override_abort {
+ test_override_abort() noexcept {
+ std::signal(SIGABRT, error_test_handle_abort);
+ }
+};
+
+test_override_abort handler{};
+
+int main() {
+ constexpr frozen::unordered_map<unsigned, unsigned, 2> ce = {{1, 2}, {3, 4}};
+ ce.at(0xDEAD);
+ return 0;
+}