preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Classes | Typedefs | Enumerations | Functions
precice::testing Namespace Reference

contains the testing framework. More...

Namespaces

namespace  com
 
namespace  inject
 

Classes

struct  ConnectionOptions
 
class  DataContextFixture
 
struct  ParallelCouplingSchemeFixture
 
struct  ParticipantState
 Represents a ParticipantState in a test. More...
 
class  precice_testsetup_fixture
 
struct  QuickTest
 
struct  Ranks
 
struct  SerialCouplingSchemeFixture
 
class  TestContext
 
struct  TestSetup
 Contains the setup description of a test including participants and requirements. More...
 
class  WaveformFixture
 
struct  WhiteboxAccessor
 struct giving access to the impl of a befriended class or struct More...
 

Typedefs

using Par = utils::Parallel
 
using ErrorPredicate = std::function<bool(::precice::Error)>
 

Enumerations

enum class  Require { PETSc , Events , Ginkgo }
 
enum struct  ConnectionType { GatherScatter , PointToPoint }
 

Functions

cplscheme::PtrCouplingData makeCouplingData (mesh::PtrData data, mesh::PtrMesh mesh, bool exchangeSubsteps)
 
cplscheme::PtrCouplingData makeCouplingData (mesh::PtrData data, mesh::PtrMesh mesh)
 
boost::unit_test::log_level getBoostTestLogLevel ()
 Boost test Initialization function.
 
std::string filterFromLogLevel (boost::unit_test::log_level logLevel)
 
void setupTestLogging ()
 
void addDummyVertices (size_t nVertices, mesh::Mesh &mesh)
 
auto makeDummy2DMesh (size_t nVertices)
 
auto makeDummy3DMesh (size_t nVertices)
 
QuickTest::Mesh operator""_mesh (const char *name, std::size_t)
 
QuickTest::ReadData operator""_read (const char *name, std::size_t)
 
QuickTest::WriteData operator""_write (const char *name, std::size_t)
 
constexpr Ranks operator""_ranks (unsigned long long value)
 
constexpr Ranks operator""_rank (unsigned long long value)
 
constexpr ParticipantState operator""_on (const char *name, std::size_t)
 User-defined literal allowing to create a serial ParticipantState from a given string.
 
DataID operator""_dataID (unsigned long long n)
 
std::string getPathToRepository ()
 Returns the base path of the repo.
 
std::string getPathToSources ()
 Returns the base path to the sources.
 
std::string getPathToTests ()
 Returns the base path to the integration tests.
 
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 getFullTestName ()
 Return the full name of the current test as seen in boost assertions.
 
TestSetup getTestSetup ()
 Returns the registered TestSetup for the test.
 
std::optional< TestSetupgetTestSetupFor (const boost::unit_test::test_unit &tu)
 Returns the registered TestSetup for a test if available.
 
int nextMeshID ()
 
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 on failure
 
boost::test_tools::predicate_result equals (const std::vector< double > &VectorA, const std::vector< double > &VectorB, double tolerance)
 
boost::test_tools::predicate_result 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 equals (double a, double b, double tolerance)
 
void expectFile (std::string_view name)
 
ErrorPredicate errorContains (std::string_view substring)
 Checks if the message of a given precice::Error contains a substring.
 
ErrorPredicate errorMatches (std::string regex)
 Checks if the message of a given precice::Error matches a regex.
 
template<class DerivedA , class DerivedB >
boost::test_tools::predicate_result 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.
 
template<typename... ARGS>
auto testSetup (ARGS... args)
 
template<typename... Args>
void expectFiles (Args... args)
 

Detailed Description

contains the testing framework.

Typedef Documentation

◆ ErrorPredicate

Definition at line 171 of file Testing.hpp.

◆ Par

Definition at line 32 of file TestContext.cpp.

Enumeration Type Documentation

◆ ConnectionType

A type of distributed connection

See also
ConnectionOptions
Enumerator
GatherScatter 
PointToPoint 

Definition at line 151 of file TestContext.hpp.

◆ Require

enum class precice::testing::Require
strong

Defines requirements for a test setup

Note
These are used for unit-tests. Integration tests calling the Participant initialize required components themselves.
Enumerator
PETSc 

Require to initialize PETSc. This implies the initialization of Events.

Events 

Require to initialize Event.

Ginkgo 

Ginkgo initialization.

Definition at line 99 of file TestContext.hpp.

Function Documentation

◆ addDummyVertices()

void precice::testing::addDummyVertices ( size_t nVertices,
mesh::Mesh & mesh )
inline

Definition at line 10 of file Meshes.hpp.

Here is the call graph for this function:

◆ equals() [1/5]

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.

Definition at line 66 of file Testing.hpp.

Here is the call graph for this function:

◆ equals() [2/5]

boost::test_tools::predicate_result precice::testing::equals ( const std::vector< double > & VectorA,
const std::vector< double > & VectorB,
double tolerance )

Definition at line 105 of file Testing.cpp.

Here is the call graph for this function:

◆ equals() [3/5]

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

Definition at line 93 of file Testing.cpp.

Here is the call graph for this function:

◆ equals() [4/5]

boost::test_tools::predicate_result precice::testing::equals ( double a,
double b,
double tolerance )

Definition at line 127 of file Testing.cpp.

Here is the call graph for this function:

◆ equals() [5/5]

boost::test_tools::predicate_result precice::testing::equals ( float a,
float b,
float tolerance )

equals to be used in tests. Compares two scalar numbers using a given tolerance. Prints both operands on failure

Definition at line 117 of file Testing.cpp.

Here is the call graph for this function:

◆ errorContains()

ErrorPredicate precice::testing::errorContains ( std::string_view substring)

Checks if the message of a given precice::Error contains a substring.

Definition at line 142 of file Testing.cpp.

Here is the call graph for this function:

◆ errorMatches()

ErrorPredicate precice::testing::errorMatches ( std::string pattern)

Checks if the message of a given precice::Error matches a regex.

Definition at line 150 of file Testing.cpp.

Here is the call graph for this function:

◆ expectFile()

void precice::testing::expectFile ( std::string_view name)

Definition at line 137 of file Testing.cpp.

Here is the call graph for this function:

◆ expectFiles()

template<typename... Args>
void precice::testing::expectFiles ( Args... args)

Definition at line 166 of file Testing.hpp.

Here is the call graph for this function:

◆ filterFromLogLevel()

std::string precice::testing::filterFromLogLevel ( boost::unit_test::log_level logLevel)

Definition at line 45 of file GlobalFixtures.cpp.

◆ getBoostTestLogLevel()

boost::unit_test::log_level precice::testing::getBoostTestLogLevel ( )

Boost test Initialization function.

Boost Test Log Levels and corresponding command line arguments to –log_level as of Boost 1.68:

type = enum boost::unit_test::log_level : int {
boost::unit_test::invalid_log_level = -1,
boost::unit_test::log_successful_tests = 0, all
boost::unit_test::log_test_units = 1, unit_scope, test_suite
boost::unit_test::log_messages = 2, message
boost::unit_test::log_warnings = 3, warning
boost::unit_test::log_all_errors = 4, error (default log level)
boost::unit_test::log_cpp_exception_errors = 5, cpp_exception
boost::unit_test::log_system_errors = 6, system_error
boost::unit_test::log_fatal_errors, fatal_error
boost::unit_test::log_nothing, nothing
}

Definition at line 34 of file GlobalFixtures.cpp.

◆ getFullTestName()

std::string precice::testing::getFullTestName ( )

Return the full name of the current test as seen in boost assertions.

Definition at line 60 of file Testing.cpp.

◆ getPathToRepository()

std::string precice::testing::getPathToRepository ( )

Returns the base path of the repo.

Definition at line 27 of file Testing.cpp.

◆ getPathToSources()

std::string precice::testing::getPathToSources ( )

Returns the base path to the sources.

Definition at line 33 of file Testing.cpp.

Here is the call graph for this function:

◆ getPathToTests()

std::string precice::testing::getPathToTests ( )

Returns the base path to the integration tests.

Definition at line 38 of file Testing.cpp.

Here is the call graph for this function:

◆ getTestName()

std::string precice::testing::getTestName ( )

Returns the name of the current test.

Definition at line 49 of file Testing.cpp.

◆ getTestPath()

std::string precice::testing::getTestPath ( )

Returns the full path to the file containing the current test.

Definition at line 43 of file Testing.cpp.

Here is the call graph for this function:

◆ getTestSetup()

TestSetup precice::testing::getTestSetup ( )

Returns the registered TestSetup for the test.

Definition at line 65 of file Testing.cpp.

Here is the call graph for this function:

◆ getTestSetupFor()

std::optional< TestSetup > precice::testing::getTestSetupFor ( const boost::unit_test::test_unit & tu)

Returns the registered TestSetup for a test if available.

Definition at line 74 of file Testing.cpp.

Here is the call graph for this function:

◆ makeCouplingData() [1/2]

cplscheme::PtrCouplingData precice::testing::makeCouplingData ( mesh::PtrData data,
mesh::PtrMesh mesh )
inline

Definition at line 10 of file helper.hpp.

Here is the call graph for this function:

◆ makeCouplingData() [2/2]

cplscheme::PtrCouplingData precice::testing::makeCouplingData ( mesh::PtrData data,
mesh::PtrMesh mesh,
bool exchangeSubsteps )
inline

Definition at line 10 of file helper.hpp.

Here is the call graph for this function:

◆ makeDummy2DMesh()

auto precice::testing::makeDummy2DMesh ( size_t nVertices)
inline

Definition at line 21 of file Meshes.hpp.

Here is the call graph for this function:

◆ makeDummy3DMesh()

auto precice::testing::makeDummy3DMesh ( size_t nVertices)
inline

Definition at line 28 of file Meshes.hpp.

Here is the call graph for this function:

◆ nextMeshID()

int precice::testing::nextMeshID ( )

Generates a new mesh id for use in tests.

Returns
a new unique mesh ID

Definition at line 86 of file Testing.cpp.

Here is the call graph for this function:

◆ operator""_dataID()

DataID precice::testing::operator""_dataID ( unsigned long long n)

Definition at line 21 of file Testing.cpp.

◆ operator""_mesh()

QuickTest::Mesh precice::testing::operator""_mesh ( const char * name,
std::size_t  )
inline

Definition at line 153 of file QuickTest.hpp.

◆ operator""_on()

constexpr ParticipantState precice::testing::operator""_on ( const char * name,
std::size_t  )
inlineconstexpr

User-defined literal allowing to create a serial ParticipantState from a given string.

Definition at line 86 of file TestContext.hpp.

◆ operator""_rank()

constexpr Ranks precice::testing::operator""_rank ( unsigned long long value)
inlineconstexpr

User-defined literal for expressively defining a single rank

Parameters
[in]valuethe amount of ranks which has to be 1
Returns
a strong typed count of 1 rank

Definition at line 40 of file TestContext.hpp.

◆ operator""_ranks()

constexpr Ranks precice::testing::operator""_ranks ( unsigned long long value)
inlineconstexpr

User-defined literal for expressively defining multiple ranks

Parameters
[in]valuethe amount of ranks <= 1
Returns
a strong typed count of ranks

Definition at line 29 of file TestContext.hpp.

◆ operator""_read()

QuickTest::ReadData precice::testing::operator""_read ( const char * name,
std::size_t  )
inline

Definition at line 158 of file QuickTest.hpp.

◆ operator""_write()

QuickTest::WriteData precice::testing::operator""_write ( const char * name,
std::size_t  )
inline

Definition at line 163 of file QuickTest.hpp.

◆ setupTestLogging()

void precice::testing::setupTestLogging ( )

Definition at line 62 of file GlobalFixtures.cpp.

Here is the call graph for this function:

◆ testSetup()

template<typename... ARGS>
auto precice::testing::testSetup ( ARGS... args)

Definition at line 146 of file Testing.hpp.