preCICE v3.2.0
Loading...
Searching...
No Matches
Testing.hpp File Reference
#include <Eigen/Core>
#include <boost/test/unit_test.hpp>
#include <functional>
#include <string>
#include <type_traits>
#include "math/differences.hpp"
#include "math/math.hpp"
#include "testing/TestContext.hpp"
#include "utils/IntraComm.hpp"
Include dependency graph for Testing.hpp:

Go to the source code of this file.

Classes

struct  precice::testing::WhiteboxAccessor
 struct giving access to the impl of a befriended class or struct More...
class  precice::testing::precice_testsetup_fixture

Namespaces

namespace  precice
 Main namespace of the precice library.
namespace  precice::testing
 contains the testing framework.
namespace  precice::testing::inject

Macros

#define PRECICE_TEST_SETUP(...)
 Creates and attaches a TestSetup to a Boost test case.
#define PRECICE_TEST()

Typedefs

using precice::testing::ErrorPredicate = std::function<bool(::precice::Error)>

Enumerations

enum class  precice::testing::inject::Require

Functions

DataID precice::testing::operator""_dataID (unsigned long long n)
template<class DerivedA, class DerivedB>
boost::test_tools::predicate_result precice::testing::equals (const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=math::NUMERICAL_ZERO_DIFFERENCE)
 equals to be used in tests. Compares two matrices using a given tolerance. Prints both operands on failure.
boost::test_tools::predicate_result precice::testing::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 on failure
boost::test_tools::predicate_result precice::testing::equals (const std::vector< double > &VectorA, const std::vector< double > &VectorB, double tolerance)
boost::test_tools::predicate_result precice::testing::equals (float a, float b, float tolerance=math::NUMERICAL_ZERO_DIFFERENCE)
 equals to be used in tests. Compares two scalar numbers using a given tolerance. Prints both operands on failure
boost::test_tools::predicate_result precice::testing::equals (double a, double b, double tolerance)
std::string precice::testing::getPathToRepository ()
 Returns the base path of the repo.
std::string precice::testing::getPathToSources ()
 Returns the base path to the sources.
std::string precice::testing::getPathToTests ()
 Returns the base path to the integration tests.
std::string precice::testing::getTestName ()
 Returns the name of the current test.
std::string precice::testing::getFullTestName ()
 Return the full name of the current test as seen in boost assertions.
std::string precice::testing::getTestPath ()
 Returns the full path to the file containing the current test.
template<typename... ARGS>
auto precice::testing::testSetup (ARGS... args)
TestSetup precice::testing::getTestSetup ()
 Returns the registered TestSetup for the test.
std::optional< TestSetupprecice::testing::getTestSetupFor (const boost::unit_test::test_unit &tu)
 Returns the registered TestSetup for a test if available.
int precice::testing::nextMeshID ()
void precice::testing::expectFile (std::string_view name)
template<typename... Args>
void precice::testing::expectFiles (Args... args)
ErrorPredicate precice::testing::errorContains (std::string_view substring)
 Checks if the message of a given precice::Error contains a substring.
ErrorPredicate precice::testing::errorMatches (std::string regex)
 Checks if the message of a given precice::Error matches a regex.

Macro Definition Documentation

◆ PRECICE_TEST

#define PRECICE_TEST ( )
Value:
if (context.invalid) { \
return; \
} \
BOOST_TEST_MESSAGE(context.describe()); \
boost::unit_test::framework::add_context(BOOST_TEST_LAZY_MSG(context.describe()), true);
bool invalid
whether this context is valid or not
std::string describe() const
Provides a user- and log-friendly description of the current context.
TestSetup getTestSetup()
Returns the registered TestSetup for the test.
Definition Testing.cpp:65

Setup the preCICE test Assigns a participant and rank from the TestSetup. Unneeded ranks are marked as invalid and skip the test. Provides a TestContext named context which can be used in the test.

Precondition
PRECICE_TEST_SETUP has been called before the test to setup a test context.

Definition at line 39 of file Testing.hpp.

◆ PRECICE_TEST_SETUP

#define PRECICE_TEST_SETUP ( ...)
Value:
BOOST_TEST_DECORATOR(*precice::testing::testSetup(__VA_ARGS__))
auto testSetup(ARGS... args)
Definition Testing.hpp:146

Creates and attaches a TestSetup to a Boost test case.

Definition at line 29 of file Testing.hpp.