24 #ifndef ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS 25 #define ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS 31 #include <type_traits> 66 std::stringstream msg;
72 #define ARM_COMPUTE_TEST_INFO(INFO) \ 74 std::stringstream info; \ 76 arm_compute::test::framework::Framework::get().add_test_info(info.str()); \ 81 #define ARM_COMPUTE_TEST_COMP_FACTORY(SEVERITY, SEVERITY_NAME, COMP, COMP_NAME, ERROR_CALL) \ 82 template <typename T, typename U> \ 83 void ARM_COMPUTE_##SEVERITY##_##COMP_NAME##_IMPL(T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level) \ 87 std::stringstream msg; \ 88 msg << #SEVERITY_NAME " '" << x_str << " " #COMP " " << y_str << "' failed. [" \ 89 << std::boolalpha << arm_compute::test::framework::make_printable(x) \ 91 << std::boolalpha << arm_compute::test::framework::make_printable(y) \ 93 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 96 arm_compute::test::framework::Framework::get().clear_test_info(); \ 108 #define ARM_COMPUTE_ASSERT_EQUAL(X, Y) \ 109 arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS) 111 #define ARM_COMPUTE_EXPECT_EQUAL(X, Y, LEVEL) \ 112 arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL) 114 #define ARM_COMPUTE_EXPECT_NOT_EQUAL(X, Y, LEVEL) \ 115 arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL) 117 #define ARM_COMPUTE_ASSERT(X) \ 123 std::stringstream msg; \ 124 msg << "Assertion '" #X "' failed.\n"; \ 125 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 126 throw arm_compute::test::framework::TestError(msg.str(), arm_compute::test::framework::LogLevel::ERRORS); \ 128 arm_compute::test::framework::Framework::get().clear_test_info(); \ 131 #define ARM_COMPUTE_EXPECT(X, LEVEL) \ 137 std::stringstream msg; \ 138 msg << "Expectation '" #X "' failed.\n"; \ 139 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 140 arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \ 142 arm_compute::test::framework::Framework::get().clear_test_info(); \ 145 #define ARM_COMPUTE_EXPECT_NO_THROW(X, LEVEL) \ 155 std::stringstream msg; \ 156 msg << "Expectation '" #X "' to not throw failed.\n"; \ 157 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 158 arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \ 160 arm_compute::test::framework::Framework::get().clear_test_info(); \ 163 #if defined(ARM_COMPUTE_ASSERTS_ENABLED) 164 #define ARM_COMPUTE_EXPECT_THROW(X, LEVEL) \ 167 bool exception_caught = false; \ 175 exception_caught = true; \ 177 if(!exception_caught) \ 179 std::stringstream msg; \ 180 msg << "Expectation '" #X "' to throw failed.\n"; \ 181 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 182 arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \ 184 arm_compute::test::framework::Framework::get().clear_test_info(); \ 186 #else // defined(ARM_COMPUTE_ASSERTS_ENABLED) 187 #define ARM_COMPUTE_EXPECT_THROW(X, LEVEL) \ 190 std::stringstream msg; \ 191 msg << "'" #X "' Skipped: asserts disabled, cannot throw\n"; \ 192 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 193 arm_compute::test::framework::Framework::get().log_info(msg.str()); \ 194 arm_compute::test::framework::Framework::get().clear_test_info(); \ 196 #endif // defined(ARM_COMPUTE_ASSERTS_ENABLED) 198 #define ARM_COMPUTE_ASSERT_FAIL(MSG) \ 201 std::stringstream msg; \ 202 msg << "Assertion '" << MSG << "' failed.\n"; \ 203 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 204 throw arm_compute::test::framework::TestError(msg.str(), arm_compute::test::framework::LogLevel::ERRORS); \ 205 arm_compute::test::framework::Framework::get().clear_test_info(); \ 208 #define ARM_COMPUTE_EXPECT_FAIL(MSG, LEVEL) \ 211 std::stringstream msg; \ 212 msg << "Expectation '" << MSG << "' failed.\n"; \ 213 arm_compute::test::framework::Framework::get().print_test_info(msg); \ 214 arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \ 215 arm_compute::test::framework::Framework::get().clear_test_info(); \
#define ARM_COMPUTE_TEST_COMP_FACTORY(SEVERITY, SEVERITY_NAME, COMP, COMP_NAME, ERROR_CALL)
#define ARM_COMPUTE_ASSERT_NOT_EQUAL(X, Y)
void print_test_info(std::ostream &os) const
Print test info.
int make_printable(int8_t value)
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
void log_info(const std::string &info)
Print the debug information that has already been logged.
WeightFormat
Memory layouts for the weights tensor.
Copyright (c) 2017-2023 Arm Limited.
static Framework & get()
Access to the singleton.
std::string to_string(const T &val)
Fallback method: try to use std::to_string:
void ARM_COMPUTE_PRINT_INFO()
void ARM_COMPUTE_ASSERT_NOT_EQUAL_IMPL(T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level)
Error class for failures during test execution.
void clear_test_info()
Clear the collected test info.