aboutsummaryrefslogtreecommitdiff
path: root/tests/framework/Asserts.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/framework/Asserts.h')
-rw-r--r--tests/framework/Asserts.h62
1 files changed, 61 insertions, 1 deletions
diff --git a/tests/framework/Asserts.h b/tests/framework/Asserts.h
index 9d6d4fad9a..7adfa8f2f3 100644
--- a/tests/framework/Asserts.h
+++ b/tests/framework/Asserts.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2022 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -30,6 +30,8 @@
#include <sstream>
#include <type_traits>
+#include "utils/TypePrinter.h"
+
namespace arm_compute
{
namespace test
@@ -42,6 +44,11 @@ inline int make_printable(int8_t value)
return value;
}
+inline std::string make_printable(const arm_compute::WeightFormat wf)
+{
+ return arm_compute::to_string(wf);
+}
+
inline unsigned int make_printable(uint8_t value)
{
return value;
@@ -135,6 +142,59 @@ ARM_COMPUTE_TEST_COMP_FACTORY(ASSERT, Assertion, !=, NOT_EQUAL, throw arm_comput
arm_compute::test::framework::Framework::get().clear_test_info(); \
} while(false)
+#define ARM_COMPUTE_EXPECT_NO_THROW(X, LEVEL) \
+ do \
+ { \
+ try \
+ { \
+ const auto &x = X; \
+ (void)x; \
+ } \
+ catch(...) \
+ { \
+ std::stringstream msg; \
+ msg << "Expectation '" #X "' to not throw failed.\n"; \
+ arm_compute::test::framework::Framework::get().print_test_info(msg); \
+ arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \
+ } \
+ arm_compute::test::framework::Framework::get().clear_test_info(); \
+ } while(false)
+
+#if defined(ARM_COMPUTE_ASSERTS_ENABLED)
+#define ARM_COMPUTE_EXPECT_THROW(X, LEVEL) \
+ do \
+ { \
+ bool exception_caught = false; \
+ try \
+ { \
+ const auto &x = X; \
+ (void)x; \
+ } \
+ catch(...) \
+ { \
+ exception_caught = true; \
+ } \
+ if(!exception_caught) \
+ { \
+ std::stringstream msg; \
+ msg << "Expectation '" #X "' to throw failed.\n"; \
+ arm_compute::test::framework::Framework::get().print_test_info(msg); \
+ arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \
+ } \
+ arm_compute::test::framework::Framework::get().clear_test_info(); \
+ } while(false)
+#else // defined(ARM_COMPUTE_ASSERTS_ENABLED)
+#define ARM_COMPUTE_EXPECT_THROW(X, LEVEL) \
+ do \
+ { \
+ std::stringstream msg; \
+ msg << "'" #X "' Skipped: asserts disabled, cannot throw\n"; \
+ arm_compute::test::framework::Framework::get().print_test_info(msg); \
+ arm_compute::test::framework::Framework::get().log_info(msg.str()); \
+ arm_compute::test::framework::Framework::get().clear_test_info(); \
+ } while(false)
+#endif // defined(ARM_COMPUTE_ASSERTS_ENABLED)
+
#define ARM_COMPUTE_ASSERT_FAIL(MSG) \
do \
{ \