unittest namespace

UnitTest declarations and definitions.

Contents

Namespaces

namespace cmd
UnitTest command line grammar definition.
namespace ctr
UnitTest control facilitating user input to internal data transfer.

Classes

class CmdLineParser
Command-line parser for UnitTest.
class UnitTestDriver
Unit test suite driver used polymorphically with tk::Driver.
class UnitTestPrint
UnitTestPrint : tk::Print.
template<class Proxy>
class MPIRunner
Generic Charm++ nodegroup chare class for running MPI unit tests.
class TUTSuite
Template Unit Test unit test suite.
template<class Proxy>
class TUTTest
Generic Charm++ chare class for unit tests utilizing the Template Unit Test library.

Functions

void operator|(PUP::er& p, tut::test_runner_singleton& runner)
void evaluate(std::vector<std::string> status, std::size_t& ncomplete, std::size_t& nwarn, std::size_t& nskip, std::size_t& nexcp, std::size_t& nfail)
Evaluate a single unit test.
auto assess(const tk::Print& print, std::size_t nfail, std::size_t nwarn, std::size_t nskip, std::size_t nexcp, std::size_t ncomplete) -> bool
Echo final assessment after the full unit test suite has finished.
template<typename T>
void veceq(const std::string& msg, const std::vector<T>& a, const std::vector<T>& b, tk::real prec = std::numeric_limits<T>::epsilon())
Ensure equality of all element of a vector of Ts (e.g., floating point numbers) up to some precision.
template<typename T, std::size_t N>
void veceq(const std::string& msg, const std::array<T, N>& a, const std::array<T, N>& b, tk::real prec = std::numeric_limits<T>::epsilon())
Ensure equality of all element of a array of Ts (e.g., floating point numbers) up to some precision.

Variables

tut::test_runner_singleton g_runner
Template Unit Test test runner.
CProxy_TUTSuite g_suiteProxy
std::string g_executable
int g_maxTestsInGroup
Max number of tests in every group.

Function documentation

void unittest::operator|(PUP::er& p, tut::test_runner_singleton& runner)

Pack/Unpack test runner. This Pack/Unpack method (re-)creates the test runner singleton on all processing elements. Therefore we circumvent Charm's usual pack/unpack for this type, and thus sizing does not make sense: sizing is a no-op. We could initialize the stack in UnitTestDriver's constructor and let this function re-create the runner only when unpacking, but that leads to repeating the same code twice: once in UnitTestDriver's constructor, once here. Another option is to use this pack/unpack routine to both initially create (when packing) and to re-create (when unpacking) the runner, which eliminates the need for pre-creating the object in UnitTestDriver's constructor and therefore eliminates the repeated code. This explains the guard for sizing: the code below is called for packing only (in serial) and packing and unpacking (in parallel).

void unittest::evaluate(std::vector<std::string> status, std::size_t& ncomplete, std::size_t& nwarn, std::size_t& nskip, std::size_t& nexcp, std::size_t& nfail)

Evaluate a single unit test.

Parameters
status in Vector of strings containing the test results. See unittest::TUTTest constructor for the expected structure of status.
ncomplete in/out Number of completed tests
nwarn in/out Number of tests with a warning
nskip in/out Number of skipped tests
nexcp in/out Number of tests with an exception
nfail in/out Number of failed tests

bool unittest::assess(const tk::Print& print, std::size_t nfail, std::size_t nwarn, std::size_t nskip, std::size_t nexcp, std::size_t ncomplete)

Echo final assessment after the full unit test suite has finished.

Parameters
print in Pretty printer
nfail in Number of failed tests
nwarn in Number of tests with a warning
nskip in Number of skipped tests
nexcp in Number of tests with an exception
ncomplete in Number of completed tests
Returns True of all tests passed, false if there was at least a failure or an exception

template<typename T>
void unittest::veceq(const std::string& msg, const std::vector<T>& a, const std::vector<T>& b, tk::real prec = std::numeric_limits<T>::epsilon())

Ensure equality of all element of a vector of Ts (e.g., floating point numbers) up to some precision.

Parameters
msg in Message to output if the vectors are not equal
in First vector to compare
in Second vector to compare
prec in Optional precision

template<typename T, std::size_t N>
void unittest::veceq(const std::string& msg, const std::array<T, N>& a, const std::array<T, N>& b, tk::real prec = std::numeric_limits<T>::epsilon())

Ensure equality of all element of a array of Ts (e.g., floating point numbers) up to some precision.

Parameters
msg in Message to output if the arrays are not equal
in First array to compare
in Second array to compare
prec in Optional precision

Variable documentation

tut::test_runner_singleton unittest::g_runner

Template Unit Test test runner.

Global-scope data. Initialized by the main chare and distibuted to all PEs by the Charm++ runtime system. Though semantically not const, all these global data should be considered read-only. See also http://charm.cs.illinois.edu/manuals/html/charm++/manual.html. The data below is global-scope because they must be available to all PEs which could be on different machines.

CProxy_TUTSuite unittest::g_suiteProxy

Test suite Charm++ proxy facilitating call-back to unit test suite by individual unit tests spawning Charm++ chares

std::string unittest::g_executable

UnitTest executable name. So that FileParser's unit tests can access a file for opening.