Celeritas 0.7-develop+0ab295a
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Functions
TestMacrosImpl.hh File Reference
#include <cstddef>
#include <iostream>
#include <iterator>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
#include <gtest/gtest.h>
#include "corecel/io/Repr.hh"
#include "corecel/math/SoftEqual.hh"
#include "TestMacrosTraits.hh"
#include "../AssertionHelper.hh"

Classes

struct  celeritas::testdetail::FailedValue< T1, T2 >
 A single index/expected/actual value. More...
 
struct  celeritas::testdetail::TCT< C1, C2 >
 
struct  celeritas::testdetail::FVIT< Iter1, Iter2 >
 
struct  celeritas::testdetail::StreamableAttr< T >
 Print an attribute with CELER_REPR_ATTR. More...
 

Namespaces

namespace  celeritas::test
 Test harness base class for optical physics.
 

Typedefs

template<class T >
using celeritas::testdetail::SoftComparator_t = EqualOr< SoftEqual< T > >
 

Functions

template<class T >
bool celeritas::test::is_soft_eq (AssertionHelper &helper, T expected, T actual, EqualOr< SoftEqual< T > > comp)
 
int celeritas::testdetail::num_digits (unsigned long val)
 Number of base-10 digits in an unsigned integer.
 
char const * celeritas::testdetail::trunc_string (int digits, char const *str, char const *trunc)
 Return a replacement string if the given string is too long.
 
::testing::AssertionResult celeritas::testdetail::IsJsonEq (char const *, char const *, std::string_view expected, std::string_view actual)
 Compare two JSON objects.
 
template<class T >
 celeritas::testdetail::StreamableAttr (char const *, T const &) -> StreamableAttr< T >
 
template<class Container >
std::enable_if_t< IsContainer_v< Container >, void > celeritas::testdetail::print_expected (Container const &data)
 Print expected values of a container.
 
template<class Result >
std::enable_if_t< IsRefResult_v< Result >, void > celeritas::testdetail::print_expected (Result const &result)
 Print expected values for a reference result with header/footer (deprecated)
 
template<class T >
void celeritas::testdetail::print_expected (T const &result, char const *var, char const *file, int line)
 Print expected values for a reference result with header/footer.
 
template<class ContainerE , class ContainerA , class Tol >
std::enable_if_t< IsContainer_v< ContainerE > &&IsContainer_v< ContainerA >, bool > celeritas::testdetail::is_ref_eq (::celeritas::test::AssertionHelper &helper, ContainerE const &val1, ContainerA const &val2, Tol &&tol)
 Compare containers of reference values using a tolerance.
 
template<class ContainerE , class ContainerA >
std::enable_if_t< IsContainer_v< ContainerE > &&IsContainer_v< ContainerA >, bool > celeritas::testdetail::is_ref_eq (::celeritas::test::AssertionHelper &helper, ContainerE const &val1, ContainerA const &val2)
 
template<class T1 , class T2 >
std::string celeritas::testdetail::failure_msg (char const *expected_expr, char const *actual_expr, std::vector< FailedValue< T1, T2 > > const &failures)
 Print failure results.
 
template<class T1 , class T2 >
std::string celeritas::testdetail::float_failure_msg (char const *expected_expr, char const *actual_expr, std::vector< FailedValue< T1, T2 > > const &failures, double abs_thresh)
 Print failure results for floating point comparisons.
 
template<class Iter1 , class Iter2 , class BinaryOp >
::testing::AssertionResult celeritas::testdetail::is_range_eq (Iter1 e_iter, Iter1 e_end, char const *expected_expr, Iter2 a_iter, Iter2 a_end, char const *actual_expr, typename FVIT< Iter1, Iter2 >::Vec_t &failures, BinaryOp comp)
 Compare a range of values.
 
template<class VE , class VA >
::testing::AssertionResult celeritas::testdetail::IsSoftEquiv (char const *expected_expr, char const *actual_expr, const VE &expected, const VA &actual)
 Predicate for relative error soft equivalence.
 
template<class VE , class VA , class T >
::testing::AssertionResult celeritas::testdetail::IsSoftEquiv (char const *expected_expr, char const *actual_expr, char const *, VE const &expected, VA const &actual, T &&cmp_or_tol)
 Predicate for relative error soft equivalence.
 
template<class ContainerE , class ContainerA , class BinaryOp >
::testing::AssertionResult celeritas::testdetail::IsVecSoftEquivImpl (ContainerE const &expected, char const *expected_expr, ContainerA const &actual, char const *actual_expr, BinaryOp comp)
 Compare vectors with soft equivalence.
 
template<class ContainerE , class ContainerA >
::testing::AssertionResult celeritas::testdetail::IsVecEq (char const *expected_expr, char const *actual_expr, ContainerE const &expected, ContainerA const &actual)
 Compare two containers.
 
template<class ContainerE , class ContainerA >
::testing::AssertionResult celeritas::testdetail::IsVecSoftEquiv (char const *expected_expr, char const *actual_expr, ContainerE const &expected, ContainerA const &actual)
 Compare two containers using soft equivalence.
 
template<class ContainerE , class ContainerA , class T >
::testing::AssertionResult celeritas::testdetail::IsVecSoftEquiv (char const *expected_expr, char const *actual_expr, char const *, ContainerE const &expected, ContainerA const &actual, T &&cmp_or_tol)
 Compare two containers using soft equivalence.
 
template<class E , class A >
::testing::AssertionResult celeritas::testdetail::IsRefEq (char const *expr1, char const *expr2, E const &expected, A const &actual)
 Dispatch reference comparison without a special tolerance.
 
template<class E , class A , class T >
::testing::AssertionResult celeritas::testdetail::IsRefEq (char const *expr1, char const *expr2, char const *tol_expr, E const &expected, A const &actual, T const &tol)
 Dispatch reference comparison using a specified tolerance.
 
template<class T >
bool celeritas::test::is_eq (AssertionHelper &helper, char const *attrname, T expected, T actual)
 Perform a soft equality comparison, appending error details on failure.
 
template<class T >
bool celeritas::test::is_soft_eq (AssertionHelper &helper, T expected, T actual, SoftComparator_t< T > comp)
 Perform a soft equality comparison, appending error details on failure.
 
template<class Container >
bool celeritas::test::is_vec_eq (AssertionHelper &helper, char const *field, Container const &expected, Container const &actual)
 Perform vector equality comparison, appending error details on failure.
 
template<class Container , class Tol >
bool celeritas::test::is_vec_soft_eq (AssertionHelper &helper, char const *field, Container const &expected, Container const &actual, Tol const &tol)
 Perform vector soft equality comparison with a tolerance, appending error details on failure.
 
template<class Container >
bool celeritas::test::is_vec_soft_eq (AssertionHelper &helper, char const *field, Container const &expected, Container const &actual)
 Perform vector soft equality comparison, appending error details on failure.
 

Function Documentation

◆ IsVecSoftEquiv()

template<class ContainerE , class ContainerA , class T >
::testing::AssertionResult celeritas::testdetail::IsVecSoftEquiv ( char const *  expected_expr,
char const *  actual_expr,
char const *  ,
ContainerE const &  expected,
ContainerA const &  actual,
T &&  cmp_or_tol 
)

Compare two containers using soft equivalence.

This signature uses the default tolerance for the appropriate floating point operations.

◆ IsVecSoftEquivImpl()

template<class ContainerE , class ContainerA , class BinaryOp >
::testing::AssertionResult celeritas::testdetail::IsVecSoftEquivImpl ( ContainerE const &  expected,
char const *  expected_expr,
ContainerA const &  actual,
char const *  actual_expr,
BinaryOp  comp 
)

Compare vectors with soft equivalence.

This signature uses the default tolerance for the appropriate floating point operations.

◆ num_digits()

int celeritas::testdetail::num_digits ( unsigned long  val)

Number of base-10 digits in an unsigned integer.

This function is useful for pre-calculating field widths for printing.

◆ print_expected()

template<class Container >
std::enable_if_t< IsContainer_v< Container >, void > celeritas::testdetail::print_expected ( Container const &  data)

Print expected values of a container.

Todo:
deprecate: use repr

◆ trunc_string()

char const * celeritas::testdetail::trunc_string ( int  digits,
char const *  str,
char const *  trunc 
)

Return a replacement string if the given string is too long.

where too long means > digits digits.