Compute Library
 21.02
Asserts.h File Reference
#include "Exceptions.h"
#include "Framework.h"
#include <sstream>
#include <type_traits>

Go to the source code of this file.

Namespaces

 arm_compute
 Copyright (c) 2017-2021 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)
 
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:170
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:160

Definition at line 110 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 101 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:170
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:160

Definition at line 179 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 98 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:170
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:224
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:160

Definition at line 124 of file Asserts.h.

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

◆ ARM_COMPUTE_EXPECT_EQUAL

◆ 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:170
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:224
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:160

Definition at line 189 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:170
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:224
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:160

Definition at line 138 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 107 of file Asserts.h.

◆ ARM_COMPUTE_EXPECT_THROW

#define ARM_COMPUTE_EXPECT_THROW (   X,
  LEVEL 
)
Value:
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"; \
} \
} while(false)
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:170
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:224
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:160

Definition at line 156 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:170
int make_printable(int8_t value)
Definition: Asserts.h:40
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:160

Definition at line 74 of file Asserts.h.

◆ ARM_COMPUTE_TEST_INFO

#define ARM_COMPUTE_TEST_INFO (   INFO)