Compute Library
 23.05
Asserts.h File Reference
#include "Exceptions.h"
#include "Framework.h"
#include <sstream>
#include <type_traits>
#include "utils/TypePrinter.h"

Go to the source code of this file.

Namespaces

 arm_compute
 Copyright (c) 2017-2023 Arm Limited.
 
 arm_compute::test
 
 arm_compute::test::framework
 
 arm_compute::test::framework::detail
 

Macros

#define ARM_COMPUTE_TEST_INFO(INFO)
 
#define ARM_COMPUTE_TEST_COMP_FACTORY(SEVERITY, SEVERITY_NAME, COMP, COMP_NAME, ERROR_CALL)
 
#define ARM_COMPUTE_ASSERT_NOT_EQUAL(X, Y)   arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS)
 
#define ARM_COMPUTE_ASSERT_EQUAL(X, Y)   arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS)
 
#define ARM_COMPUTE_EXPECT_EQUAL(X, Y, LEVEL)   arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL)
 
#define ARM_COMPUTE_EXPECT_NOT_EQUAL(X, Y, LEVEL)   arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL)
 
#define ARM_COMPUTE_ASSERT(X)
 
#define ARM_COMPUTE_EXPECT(X, LEVEL)
 
#define ARM_COMPUTE_EXPECT_NO_THROW(X, LEVEL)
 
#define ARM_COMPUTE_EXPECT_THROW(X, LEVEL)
 
#define ARM_COMPUTE_ASSERT_FAIL(MSG)
 
#define ARM_COMPUTE_EXPECT_FAIL(MSG, LEVEL)
 

Functions

int make_printable (int8_t value)
 
std::string make_printable (const arm_compute::WeightFormat wf)
 
unsigned int make_printable (uint8_t value)
 
template<typename T >
make_printable (T &&value)
 
void ARM_COMPUTE_PRINT_INFO ()
 
template<typename T , typename U >
void ARM_COMPUTE_EXPECT_EQUAL_IMPL (T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level)
 
template<typename T , typename U >
void ARM_COMPUTE_EXPECT_NOT_EQUAL_IMPL (T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level)
 
template<typename T , typename U >
void ARM_COMPUTE_ASSERT_EQUAL_IMPL (T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level)
 
template<typename T , typename U >
void ARM_COMPUTE_ASSERT_NOT_EQUAL_IMPL (T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level)
 

Macro Definition Documentation

◆ ARM_COMPUTE_ASSERT

#define ARM_COMPUTE_ASSERT (   X)
Value:
do \
{ \
const auto &x = X; \
if(!x) \
{ \
std::stringstream msg; \
msg << "Assertion '" #X "' failed.\n"; \
} \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
#define X(model)
Definition: CPPTypes.h:61
Error class for failures during test execution.
Definition: Exceptions.h:78
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 117 of file Asserts.h.

◆ ARM_COMPUTE_ASSERT_EQUAL

#define ARM_COMPUTE_ASSERT_EQUAL (   X,
 
)    arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS)

Definition at line 108 of file Asserts.h.

◆ ARM_COMPUTE_ASSERT_FAIL

#define ARM_COMPUTE_ASSERT_FAIL (   MSG)
Value:
do \
{ \
std::stringstream msg; \
msg << "Assertion '" << MSG << "' failed.\n"; \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
Error class for failures during test execution.
Definition: Exceptions.h:78
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 198 of file Asserts.h.

◆ ARM_COMPUTE_ASSERT_NOT_EQUAL

#define ARM_COMPUTE_ASSERT_NOT_EQUAL (   X,
 
)    arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS)

Definition at line 105 of file Asserts.h.

◆ ARM_COMPUTE_EXPECT

#define ARM_COMPUTE_EXPECT (   X,
  LEVEL 
)
Value:
do \
{ \
const auto &x = X; \
if(!x) \
{ \
std::stringstream msg; \
msg << "Expectation '" #X "' failed.\n"; \
} \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:226
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
#define X(model)
Definition: CPPTypes.h:61
Error class for failures during test execution.
Definition: Exceptions.h:78
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 131 of file Asserts.h.

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and arm_compute::test::validation::TEST_CASE().

◆ ARM_COMPUTE_EXPECT_EQUAL

#define ARM_COMPUTE_EXPECT_EQUAL (   X,
  Y,
  LEVEL 
)    arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL)

Definition at line 111 of file Asserts.h.

◆ ARM_COMPUTE_EXPECT_FAIL

#define ARM_COMPUTE_EXPECT_FAIL (   MSG,
  LEVEL 
)
Value:
do \
{ \
std::stringstream msg; \
msg << "Expectation '" << MSG << "' failed.\n"; \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:226
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
Error class for failures during test execution.
Definition: Exceptions.h:78
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 208 of file Asserts.h.

◆ ARM_COMPUTE_EXPECT_NO_THROW

#define ARM_COMPUTE_EXPECT_NO_THROW (   X,
  LEVEL 
)
Value:
do \
{ \
try \
{ \
const auto &x = X; \
(void)x; \
} \
catch(...) \
{ \
std::stringstream msg; \
msg << "Expectation '" #X "' to not throw failed.\n"; \
} \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:226
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
#define X(model)
Definition: CPPTypes.h:61
Error class for failures during test execution.
Definition: Exceptions.h:78
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 145 of file Asserts.h.

Referenced by arm_compute::test::validation::TEST_CASE().

◆ ARM_COMPUTE_EXPECT_NOT_EQUAL

#define ARM_COMPUTE_EXPECT_NOT_EQUAL (   X,
  Y,
  LEVEL 
)    arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL)

Definition at line 114 of file Asserts.h.

◆ ARM_COMPUTE_EXPECT_THROW

#define ARM_COMPUTE_EXPECT_THROW (   X,
  LEVEL 
)
Value:
do \
{ \
std::stringstream msg; \
msg << "'" #X "' Skipped: asserts disabled, cannot throw\n"; \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
void log_info(const std::string &info)
Print the debug information that has already been logged.
Definition: Framework.cpp:244
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
#define X(model)
Definition: CPPTypes.h:61
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 187 of file Asserts.h.

Referenced by arm_compute::test::validation::TEST_CASE().

◆ ARM_COMPUTE_TEST_COMP_FACTORY

#define ARM_COMPUTE_TEST_COMP_FACTORY (   SEVERITY,
  SEVERITY_NAME,
  COMP,
  COMP_NAME,
  ERROR_CALL 
)
Value:
template <typename T, typename U> \
void ARM_COMPUTE_##SEVERITY##_##COMP_NAME##_IMPL(T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level) \
{ \
if(!(x COMP y)) \
{ \
std::stringstream msg; \
msg << #SEVERITY_NAME " '" << x_str << " " #COMP " " << y_str << "' failed. [" \
<< " " #COMP " " \
<< "]\n"; \
ERROR_CALL \
} \
}
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:171
int make_printable(int8_t value)
Definition: Asserts.h:42
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
LogLevel
Logging level enumeration.
Definition: Types.h:34
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:161

Definition at line 81 of file Asserts.h.

◆ ARM_COMPUTE_TEST_INFO

#define ARM_COMPUTE_TEST_INFO (   INFO)
Value:
{ \
std::stringstream info; \
info << INFO; \
}
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void add_test_info(std::string info)
Add info string for the next expectation/assertion.
Definition: Framework.cpp:156

Definition at line 72 of file Asserts.h.

Referenced by arm_compute::test::validation::combine(), arm_compute::test::validation::FIXTURE_DATA_TEST_CASE(), arm_compute::test::validation::FIXTURE_DATA_TEST_CASE_NEW(), arm_compute::test::validation::validate(), and arm_compute::test::validation::validate_wrap().