Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_LocalTestingHelpers.hpp File Reference

Utilities to make writing tests easier. More...

Include dependency graph for Teuchos_LocalTestingHelpers.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ECHO(statement)
 Echo the given statement before it is executed.
#define TEST_ASSERT(v1)
 Assert the given statement is true.
#define TEST_EQUALITY_CONST(v1, v2)
 Assert the equality of v1 and constant v2.
#define TEST_EQUALITY(v1, v2)
 Assert the equality of v1 and v2.
#define TEST_INEQUALITY_CONST(v1, v2)
 Assert the inequality of v1 and constant v2.
#define TEST_INEQUALITY(v1, v2)
 Assert the inequality of v1 and v2.
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
 Assert the relative floating-point equality of rel_error(v1,v2) <= tol.
#define TEST_ITER_EQUALITY(iter1, iter2)
 Assert that two iterators are equal.
#define TEST_ITER_INEQUALITY(iter1, iter2)
 Assert that two iterators are NOT equal.
#define TEST_ARRAY_ELE_EQUALITY(a, i, val)
 Assert that a[i] == val.
#define TEST_ARRAY_ELE_INEQUALITY(a, i, val)
 Assert that a[i] != val.
#define TEST_COMPARE(v1, comp, v2)
 Assert that v1 comp v2 (where comp = '==', '>=", "!=", etc).
#define TEST_COMPARE_CONST(v1, comp, v2)
 Assert that v1 comp v2 (where comp = '==', '>=", "!=", etc) where the second object v2 is printed as value.
#define TEST_COMPARE_ARRAYS(a1, a2)
 Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
#define TEST_COMPARE_FLOATING_ARRAYS(a1, a2, tol)
 Assert that a1.size()==a2.size() and rel_error(a[i],b[i]) <= tol, i=0....
#define TEST_THROW(code, ExceptType)
 Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails).
#define TEST_NOTHROW(code)
 Asserr that the statement 'code' does not thrown any excpetions.

Detailed Description

Utilities to make writing tests easier.

WARNING! These macros are not namespaced, so you must only include it in *.cpp files for unit testing only!

Definition in file Teuchos_LocalTestingHelpers.hpp.

Macro Definition Documentation

◆ ECHO

#define ECHO ( statement)
Value:
TEUCHOS_ECHO( statement, out )
#define TEUCHOS_ECHO(statement, out)
Echo a statement and then invoke it.

Echo the given statement before it is executed.

Definition at line 63 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_ASSERT

#define TEST_ASSERT ( v1)
Value:
TEUCHOS_TEST_ASSERT( v1, out, success )
#define TEUCHOS_TEST_ASSERT(v1, out, success)
Assert that a give object is true.

Assert the given statement is true.

Definition at line 71 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_EQUALITY_CONST

#define TEST_EQUALITY_CONST ( v1,
v2 )
Value:
TEUCHOS_TEST_EQUALITY_CONST( v1, v2, out, success )
#define TEUCHOS_TEST_EQUALITY_CONST(v1, v2, out, success)
Test that an object is equal to a given constant.

Assert the equality of v1 and constant v2.

Definition at line 79 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_EQUALITY

#define TEST_EQUALITY ( v1,
v2 )
Value:
TEUCHOS_TEST_EQUALITY( v1, v2, out, success )
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
Test that two values are equal.

Assert the equality of v1 and v2.

Definition at line 87 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_INEQUALITY_CONST

#define TEST_INEQUALITY_CONST ( v1,
v2 )
Value:
TEUCHOS_TEST_INEQUALITY_CONST( v1, v2, out, success )
#define TEUCHOS_TEST_INEQUALITY_CONST(v1, v2, out, success)
Test that an object is not equal to a given constant.

Assert the inequality of v1 and constant v2.

Definition at line 95 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_INEQUALITY

#define TEST_INEQUALITY ( v1,
v2 )
Value:
TEUCHOS_TEST_INEQUALITY( v1, v2, out, success )
#define TEUCHOS_TEST_INEQUALITY(v1, v2, out, success)
Test that two values are not equal.

Assert the inequality of v1 and v2.

Definition at line 103 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_FLOATING_EQUALITY

#define TEST_FLOATING_EQUALITY ( v1,
v2,
tol )
Value:
TEUCHOS_TEST_FLOATING_EQUALITY( v1, v2, tol, out, success )
#define TEUCHOS_TEST_FLOATING_EQUALITY(v1, v2, tol, out, success)
Test if two floating point values are equal to a given tolerance.

Assert the relative floating-point equality of rel_error(v1,v2) <= tol.

Definition at line 112 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_ITER_EQUALITY

#define TEST_ITER_EQUALITY ( iter1,
iter2 )
Value:
TEUCHOS_TEST_ITER_EQUALITY( iter1, iter2, out, success )
#define TEUCHOS_TEST_ITER_EQUALITY(iter1, iter2, out, success)
Test if two iterators are equal.

Assert that two iterators are equal.

Definition at line 120 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_ITER_INEQUALITY

#define TEST_ITER_INEQUALITY ( iter1,
iter2 )
Value:
TEUCHOS_TEST_ITER_INEQUALITY( iter1, iter2, out, success )
#define TEUCHOS_TEST_ITER_INEQUALITY(iter1, iter2, out, success)
Test if two iterators are NOT equal.

Assert that two iterators are NOT equal.

Definition at line 128 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_ARRAY_ELE_EQUALITY

#define TEST_ARRAY_ELE_EQUALITY ( a,
i,
val )
Value:
TEUCHOS_TEST_ARRAY_ELE_EQUALITY( a, i, val, false, out, local_success )
#define TEUCHOS_TEST_ARRAY_ELE_EQUALITY(a, i, val, printPass, out, success)
Test that an array element value is equal to a given constant.

Assert that a[i] == val.

Definition at line 136 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_ARRAY_ELE_INEQUALITY

#define TEST_ARRAY_ELE_INEQUALITY ( a,
i,
val )
Value:
TEUCHOS_TEST_ARRAY_ELE_INEQUALITY( a, i, val, false, out, local_success )
#define TEUCHOS_TEST_ARRAY_ELE_INEQUALITY(a, i, val, printPass, out, success)
Test that an array element value is not equal to a given constant.

Assert that a[i] != val.

Definition at line 144 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_COMPARE

#define TEST_COMPARE ( v1,
comp,
v2 )
Value:
TEUCHOS_TEST_COMPARE( v1, comp, v2, out, success )
#define TEUCHOS_TEST_COMPARE(v1, comp, v2, out, success)
Compare two objects using an input comparsion operator.

Assert that v1 comp v2 (where comp = '==', '>=", "!=", etc).

Definition at line 152 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_COMPARE_CONST

#define TEST_COMPARE_CONST ( v1,
comp,
v2 )
Value:
TEUCHOS_TEST_COMPARE_CONST( v1, comp, v2, out, success )
#define TEUCHOS_TEST_COMPARE_CONST(v1, comp, v2, out, success)
Compare an object and a constant using an input comparsion operator.

Assert that v1 comp v2 (where comp = '==', '>=", "!=", etc) where the second object v2 is printed as value.

Definition at line 161 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_COMPARE_ARRAYS

#define TEST_COMPARE_ARRAYS ( a1,
a2 )
Value:
{ \
const bool l_result = compareArrays(a1,#a1,a2,#a2,out); \
if (!l_result) success = false; \
}

Assert that a1.size()==a2.size() and a[i]==b[i], i=0....

Works for any object types that support a1[i], a1.size(), a2[j], and a2.size() and types a1 and a2 can be different types!

Definition at line 172 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_COMPARE_FLOATING_ARRAYS

#define TEST_COMPARE_FLOATING_ARRAYS ( a1,
a2,
tol )
Value:
{ \
const bool result = compareFloatingArrays(a1,#a1,a2,#a2,tol,out); \
if (!result) success = false; \
}

Assert that a1.size()==a2.size() and rel_error(a[i],b[i]) <= tol, i=0....

Works for any object types that support a1[i], a1.size(), a2[j], and a2.size() and types a1 and a2 can be different types!

Definition at line 186 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_THROW

#define TEST_THROW ( code,
ExceptType )
Value:
TEUCHOS_TEST_THROW( code, ExceptType, out, success )
#define TEUCHOS_TEST_THROW(code, ExceptType, out, success)
Test that the chunk of code 'code' throws an expected exception.

Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails).

Definition at line 198 of file Teuchos_LocalTestingHelpers.hpp.

◆ TEST_NOTHROW

#define TEST_NOTHROW ( code)
Value:
TEUCHOS_TEST_NOTHROW( code, out, success )
#define TEUCHOS_TEST_NOTHROW(code, out, success)
Test that a chunk of code does not throw any exceptions.

Asserr that the statement 'code' does not thrown any excpetions.

Definition at line 206 of file Teuchos_LocalTestingHelpers.hpp.