From 65a8349aa5526d071b18cd4d42586c46faaa3823 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 24 Nov 2025 02:13:48 +0100 Subject: feat! breaking changes for OCL v1.0.48. Signed-off-by: Amlal El Mahrouss --- include/ocl/tests/gtest.hpp | 10 +++++ include/ocl/tests/hpptest.hpp | 90 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 include/ocl/tests/gtest.hpp create mode 100644 include/ocl/tests/hpptest.hpp (limited to 'include/ocl/tests') diff --git a/include/ocl/tests/gtest.hpp b/include/ocl/tests/gtest.hpp new file mode 100644 index 0000000..ee328b0 --- /dev/null +++ b/include/ocl/tests/gtest.hpp @@ -0,0 +1,10 @@ +/* + * File: tests/gtest.hpp + * Purpose: Google Test wrapper for the OCL library. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. + */ + +#pragma once + +#include diff --git a/include/ocl/tests/hpptest.hpp b/include/ocl/tests/hpptest.hpp new file mode 100644 index 0000000..0c7b4e5 --- /dev/null +++ b/include/ocl/tests/hpptest.hpp @@ -0,0 +1,90 @@ +/* + * File: tests/hpptest.hpp + * Purpose: HPP Test wrapper for the OCL library. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. + */ + +#pragma once + +#include +#include + +namespace ocl::hpptest +{ + /// @brief Standard termination error handler, called when a test fails. + struct standard_terminate final + { + template + static void error() noexcept + { + ocl::io::print("standard_terminate::error, terminating...\n"); + + if (stop_execution) + std::terminate(); + } + }; + + struct posix_terminate final + { + template + static void error(errno_t err) noexcept + { + ocl::io::print("posix_terminate::error: expected=", strerror(args), ", got=", strerror(err), "\n"); + + if (stop_execution) + std::terminate(); + } + }; + + typedef bool condition_type; + + template + consteval inline void must_be() + { +#ifdef OCL_HPPTEST + OCL_HPPTEST_ASSERT(expr); +#endif // _WIN32 + } + + template + inline void must_be(condition_type cond) noexcept + { + if (cond != expect) + { + on_fail::template error(); + } + } + + template + inline void must_be(errno_t ern) noexcept + { + if (ern != expect) + { + posix_terminate::error(ern); + } + } + +#ifdef _WIN32 + struct win32_terminate final + { + template + static void error(HRESULT err) noexcept + { + ocl::io::print("win32_terminate::error: expected=S_OK, got=", err, "\n"); + + if (stop_execution) + std::terminate(); + } + }; + + template + inline void must_be(HRESULT hr) noexcept + { + if (hr != expect) + { + win32_terminate::error(hr); + } + } +#endif // _WIN32 +} // namespace ocl::hpptest -- cgit v1.2.3