4#include <boost/test/unit_test.hpp>
15namespace bt = boost::unit_test;
17DataID operator"" _dataID(
unsigned long long n);
21using precice::testing::operator
""_rank;
22using precice::testing::operator
""_ranks;
23using precice::testing::operator
""_on;
24using precice::testing::operator
""_dataID;
27#define PRECICE_TEST(...) \
28 using namespace precice::testing::inject; \
29 precice::testing::TestContext context{__VA_ARGS__}; \
30 if (context.invalid) { \
33 BOOST_TEST_MESSAGE(context.describe()); \
34 boost::unit_test::framework::add_context(BOOST_TEST_LAZY_MSG(context.describe()), true);
54template <
class DerivedA,
class DerivedB>
55boost::test_tools::predicate_result
equals(
const Eigen::MatrixBase<DerivedA> &A,
56 const Eigen::MatrixBase<DerivedB> &B,
59 auto approx = [tolerance](
double a,
double b) ->
bool {
60 if (
std::max(std::abs(a), std::abs(b)) < tolerance) {
63 return std::abs(a - b) <= tolerance *
std::max(std::abs(a), std::abs(b));
67 if (!A.binaryExpr(B, approx).all()) {
68 boost::test_tools::predicate_result res(
false);
69 Eigen::IOFormat format;
71 format.rowSeparator =
", ";
72 format.rowPrefix =
" ";
73 format.precision = Eigen::FullPrecision;
76 << A.format(format) <<
" != \n"
77 << B.format(format) <<
'\n'
78 << (A - B).cwiseAbs().format(format) <<
" difference\n"
79 << A.binaryExpr(B, approx).format(format) <<
"in tolerance (" << tolerance <<
')';
constexpr double NUMERICAL_ZERO_DIFFERENCE
contains the testing framework.
boost::test_tools::predicate_result equals(const std::vector< float > &VectorA, const std::vector< float > &VectorB, float tolerance)
equals to be used in tests. Compares two std::vectors using a given tolerance. Prints both operands o...
std::string getPathToRepository()
Returns the base path of the repo.
std::string getTestPath()
Returns the full path to the file containing the current test.
std::string getTestName()
Returns the name of the current test.
std::string getPathToTests()
Returns the base path to the integration tests.
std::string getPathToSources()
Returns the base path to the sources.
struct giving access to the impl of a befriended class or struct
static auto impl(T &obj) -> typename std::add_lvalue_reference< decltype(*(obj._impl))>::type