ReFRACtor
unit_test_support.h File Reference
#include "global_fixture.h"
#include "ifstream_cs.h"
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <blitz/array.h>
#include <string>
+ Include dependency graph for unit_test_support.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BOOST_CHECK_ARRAYAD_CLOSE(A, B)   BOOST_CHECK_MATRIX_CLOSE(A.value(), B.value()); BOOST_CHECK_MATRIX_CLOSE(A.jacobian(), B.jacobian())
 
#define BOOST_CHECK_ARRAYAD_CLOSE_TOL(A, B, tol)   BOOST_CHECK_MATRIX_CLOSE_TOL(A.value(), B.value(), tol); BOOST_CHECK_MATRIX_CLOSE_TOL(A.jacobian(), B.jacobian(), tol)
 Check for two ArrayAd being equal. More...
 
#define BOOST_CHECK_MATRIX_CLOSE(A, B)   BOOST_CHECK_MATRIX_CLOSE_TOL(A, B, 1e-8)
 
#define BOOST_CHECK_MATRIX_CLOSE_TOL(A, B, tol)   BOOST_CHECK_LT(max(abs(A - (B))), tol)
 Check for two matrixes being equal. More...
 
#define CHECK_THROW_EXCEPTION(S, V)
 Throw Exception, with string the given value. More...
 
#define is_long_test()
 Mark as test as "long". More...
 
#define is_really_long_test()
 
#define is_timing_test()
 Mark as test as "timing". More...
 

Functions

template<class T >
void compare_item_by_item (const blitz::Array< T, 1 > &A, const blitz::Array< T, 1 > &B, double tol, bool show_all=false)
 Go through two 1D arrays and compare items item by item. More...
 
template<class T >
void compare_item_by_item (const blitz::Array< T, 2 > &A, const blitz::Array< T, 2 > &B, double tol, bool show_all=false)
 Go through two 2D arrays and compare items item by item. More...
 
template<class T >
void compare_item_by_item (const blitz::Array< T, 3 > &A, const blitz::Array< T, 3 > &B, double tol, bool show_all=false)
 Go through two 3D arrays and compare items item by item. More...
 
template<class T >
void compare_item_by_item (const blitz::Array< T, 4 > &A, const blitz::Array< T, 4 > &B, double tol, bool show_all=false)
 Go through two 4D arrays and compare items item by item. More...
 
template<class T , int N>
void compare_shapes (const blitz::Array< T, N > &A, const blitz::Array< T, N > &B)
 

Macro Definition Documentation

◆ BOOST_CHECK_ARRAYAD_CLOSE

#define BOOST_CHECK_ARRAYAD_CLOSE (   A,
 
)    BOOST_CHECK_MATRIX_CLOSE(A.value(), B.value()); BOOST_CHECK_MATRIX_CLOSE(A.jacobian(), B.jacobian())

Definition at line 29 of file unit_test_support.h.

◆ BOOST_CHECK_ARRAYAD_CLOSE_TOL

#define BOOST_CHECK_ARRAYAD_CLOSE_TOL (   A,
  B,
  tol 
)    BOOST_CHECK_MATRIX_CLOSE_TOL(A.value(), B.value(), tol); BOOST_CHECK_MATRIX_CLOSE_TOL(A.jacobian(), B.jacobian(), tol)

Check for two ArrayAd being equal.

Definition at line 28 of file unit_test_support.h.

◆ BOOST_CHECK_MATRIX_CLOSE

#define BOOST_CHECK_MATRIX_CLOSE (   A,
 
)    BOOST_CHECK_MATRIX_CLOSE_TOL(A, B, 1e-8)

Definition at line 22 of file unit_test_support.h.

◆ BOOST_CHECK_MATRIX_CLOSE_TOL

#define BOOST_CHECK_MATRIX_CLOSE_TOL (   A,
  B,
  tol 
)    BOOST_CHECK_LT(max(abs(A - (B))), tol)

Check for two matrixes being equal.

Definition at line 21 of file unit_test_support.h.

◆ CHECK_THROW_EXCEPTION

#define CHECK_THROW_EXCEPTION (   S,
 
)
Value:
try { \
S; \
BOOST_ERROR("Exception was not thrown"); \
} catch(const FullPhysics::Exception& E) { \
BOOST_CHECK_EQUAL(std::string(E.what()), std::string(V)) ; \
}
virtual const char * what() const
Description of what the error is.
Definition: fp_exception.h:88
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16

Throw Exception, with string the given value.

Definition at line 35 of file unit_test_support.h.

◆ is_long_test

#define is_long_test ( )
Value:
if(!getenv("L2_FP_LONG_CHECK") && !getenv("L2_FP_REALLY_LONG_CHECK")) { \
BOOST_WARN_MESSAGE(false, "Skipping long test. To run, make long_check"); \
return; \
}

Mark as test as "long".

We only run these tests when doing "long_check", the normal "check" doesn't run these. This is handled by checking for the environment variable L2_FP_LONG_CHECK (so when debugging long tests you need to define this environment variable)

Definition at line 142 of file unit_test_support.h.

◆ is_really_long_test

#define is_really_long_test ( )
Value:
if(!getenv("L2_FP_REALLY_LONG_CHECK")) { \
BOOST_WARN_MESSAGE(false, "Skipping really long test. To run, make really_long_check"); \
return; \
}

Definition at line 148 of file unit_test_support.h.

◆ is_timing_test

#define is_timing_test ( )
Value:
if(!getenv("L2_FP_TIMING_CHECK")) { \
BOOST_WARN_MESSAGE(false, "Skipping timing test. To run, make timing_check"); \
return; \
}

Mark as test as "timing".

We only run these tests when doing "timing_check", the normal "check" doesn't run these. This is handled by checking for the environment variable L2_FP_TIMING_CHECK (so when debugging long tests you need to define this environment variable)

Definition at line 162 of file unit_test_support.h.

Function Documentation

◆ compare_item_by_item() [1/4]

template<class T >
void compare_item_by_item ( const blitz::Array< T, 1 > &  A,
const blitz::Array< T, 1 > &  B,
double  tol,
bool  show_all = false 
)
inline

Go through two 1D arrays and compare items item by item.

Definition at line 55 of file unit_test_support.h.

◆ compare_item_by_item() [2/4]

template<class T >
void compare_item_by_item ( const blitz::Array< T, 2 > &  A,
const blitz::Array< T, 2 > &  B,
double  tol,
bool  show_all = false 
)
inline

Go through two 2D arrays and compare items item by item.

Definition at line 73 of file unit_test_support.h.

◆ compare_item_by_item() [3/4]

template<class T >
void compare_item_by_item ( const blitz::Array< T, 3 > &  A,
const blitz::Array< T, 3 > &  B,
double  tol,
bool  show_all = false 
)
inline

Go through two 3D arrays and compare items item by item.

Definition at line 93 of file unit_test_support.h.

◆ compare_item_by_item() [4/4]

template<class T >
void compare_item_by_item ( const blitz::Array< T, 4 > &  A,
const blitz::Array< T, 4 > &  B,
double  tol,
bool  show_all = false 
)
inline

Go through two 4D arrays and compare items item by item.

Definition at line 115 of file unit_test_support.h.

◆ compare_shapes()

template<class T , int N>
void compare_shapes ( const blitz::Array< T, N > &  A,
const blitz::Array< T, N > &  B 
)
inline

Definition at line 44 of file unit_test_support.h.


Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11