jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Macros | Functions
catch2_ext.hpp File Reference
#include <catch2/catch_amalgamated.hpp>
#include <jau/float_math.hpp>
#include <jau/test/catch2_my_main.cpp>
Include dependency graph for catch2_ext.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COMPARE_NARRAYS(lhs, rhs, len)   compareNativeArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs, len)
 
#define COMPARE_NARRAYS_EPS(lhs, rhs, len, eps)   compareNativeArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs, len, eps)
 
#define COMPARE_SARRAYS(lhs, rhs)   compareStdArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs)
 
#define COMPARE_SARRAYS_EPS(lhs, rhs, eps)   compareStdArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs, eps)
 
#define INFO_STR(msg)   INTERNAL_CATCH_INFO( "INFO", static_cast<std::string>(msg) )
 
#define INTERNAL_CATCH_TEST_M(msg, macroName, resultDisposition, ...)
 
#define INTERNAL_CHECK_THAT_M(msg, macroName, matcher, resultDisposition, arg)
 
#define REQUIRE_DIFF(a, b, d)   INTERNAL_CATCH_TEST( "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b, 1, d))
 
#define REQUIRE_DIFF_MSG(m, a, b, d)   INTERNAL_CATCH_TEST_M( m, "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b, 1, d))
 
#define REQUIRE_EPSI(a, b)   INTERNAL_CATCH_TEST( "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b))
 
#define REQUIRE_EPSI_MSG(m, a, b)   INTERNAL_CATCH_TEST_M( m, "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b))
 
#define REQUIRE_MSG(MSG, ...)   INTERNAL_CATCH_TEST_M( MSG, "REQUIRE: ", Catch::ResultDisposition::Normal, __VA_ARGS__ )
 
#define REQUIRE_THAT_MSG(MSG, arg, matcher)   INTERNAL_CHECK_THAT_M( MSG, "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
 

Functions

template<typename T >
void compareNativeArrays (const std::string &test, unsigned line, const T lhs[], const T rhs[], const size_t len)
 
template<typename T >
void compareNativeArrays (const std::string &test, unsigned line, const T lhs[], const T rhs[], const size_t len, const T epsilon)
 
template<typename T , size_t N>
void compareStdArrays (const std::string &test, unsigned line, const std::array< T, N > &lhs, const std::array< T, N > &rhs)
 
template<typename T , size_t N>
void compareStdArrays (const std::string &test, unsigned line, const std::array< T, N > &lhs, const std::array< T, N > &rhs, const T epsilon)
 

Macro Definition Documentation

◆ INTERNAL_CATCH_TEST_M

#define INTERNAL_CATCH_TEST_M (   msg,
  macroName,
  resultDisposition,
  ... 
)
Value:
do { \
/* The expression should not be evaluated, but warnings should hopefully be checked */ \
CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \
std::string s1( macroName##_catch_sr ); \
s1.append(msg); \
s1.append(": "); \
Catch::AssertionHandler catchAssertionHandler( s1, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \
INTERNAL_CATCH_TRY { \
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
} while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) )

Definition at line 41 of file catch2_ext.hpp.

◆ REQUIRE_MSG

#define REQUIRE_MSG (   MSG,
  ... 
)    INTERNAL_CATCH_TEST_M( MSG, "REQUIRE: ", Catch::ResultDisposition::Normal, __VA_ARGS__ )

◆ INTERNAL_CHECK_THAT_M

#define INTERNAL_CHECK_THAT_M (   msg,
  macroName,
  matcher,
  resultDisposition,
  arg 
)
Value:
do { \
std::string s1( macroName##_catch_sr ); \
s1.append(": "); \
s1.append(msg); \
s1.append(": "); \
Catch::AssertionHandler catchAssertionHandler( s1, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
INTERNAL_CATCH_TRY { \
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
} while( false )

Definition at line 60 of file catch2_ext.hpp.

◆ REQUIRE_THAT_MSG

#define REQUIRE_THAT_MSG (   MSG,
  arg,
  matcher 
)    INTERNAL_CHECK_THAT_M( MSG, "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )

Definition at line 73 of file catch2_ext.hpp.

◆ INFO_STR

#define INFO_STR (   msg)    INTERNAL_CATCH_INFO( "INFO", static_cast<std::string>(msg) )

◆ REQUIRE_EPSI

#define REQUIRE_EPSI (   a,
 
)    INTERNAL_CATCH_TEST( "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b))

Definition at line 77 of file catch2_ext.hpp.

◆ REQUIRE_EPSI_MSG

#define REQUIRE_EPSI_MSG (   m,
  a,
 
)    INTERNAL_CATCH_TEST_M( m, "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b))

Definition at line 78 of file catch2_ext.hpp.

◆ REQUIRE_DIFF

#define REQUIRE_DIFF (   a,
  b,
 
)    INTERNAL_CATCH_TEST( "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b, 1, d))

Definition at line 80 of file catch2_ext.hpp.

◆ REQUIRE_DIFF_MSG

#define REQUIRE_DIFF_MSG (   m,
  a,
  b,
 
)    INTERNAL_CATCH_TEST_M( m, "REQUIRE: ", Catch::ResultDisposition::Normal, jau::equals(a, b, 1, d))

Definition at line 81 of file catch2_ext.hpp.

◆ COMPARE_SARRAYS

#define COMPARE_SARRAYS (   lhs,
  rhs 
)    compareStdArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs)

Definition at line 84 of file catch2_ext.hpp.

◆ COMPARE_SARRAYS_EPS

#define COMPARE_SARRAYS_EPS (   lhs,
  rhs,
  eps 
)    compareStdArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs, eps)

Definition at line 85 of file catch2_ext.hpp.

◆ COMPARE_NARRAYS

#define COMPARE_NARRAYS (   lhs,
  rhs,
  len 
)    compareNativeArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs, len)

Definition at line 101 of file catch2_ext.hpp.

◆ COMPARE_NARRAYS_EPS

#define COMPARE_NARRAYS_EPS (   lhs,
  rhs,
  len,
  eps 
)    compareNativeArrays(Catch::getResultCapture().getCurrentTestName(), __LINE__, lhs, rhs, len, eps)

Definition at line 102 of file catch2_ext.hpp.

Function Documentation

◆ compareStdArrays() [1/2]

template<typename T , size_t N>
void compareStdArrays ( const std::string &  test,
unsigned  line,
const std::array< T, N > &  lhs,
const std::array< T, N > &  rhs 
)

Definition at line 88 of file catch2_ext.hpp.

◆ compareStdArrays() [2/2]

template<typename T , size_t N>
void compareStdArrays ( const std::string &  test,
unsigned  line,
const std::array< T, N > &  lhs,
const std::array< T, N > &  rhs,
const T  epsilon 
)

Definition at line 94 of file catch2_ext.hpp.

◆ compareNativeArrays() [1/2]

template<typename T >
void compareNativeArrays ( const std::string &  test,
unsigned  line,
const T  lhs[],
const T  rhs[],
const size_t  len 
)

Definition at line 105 of file catch2_ext.hpp.

◆ compareNativeArrays() [2/2]

template<typename T >
void compareNativeArrays ( const std::string &  test,
unsigned  line,
const T  lhs[],
const T  rhs[],
const size_t  len,
const T  epsilon 
)

Definition at line 112 of file catch2_ext.hpp.