Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros
Unit Testing Assert Macros

Macros

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

Detailed Description

These are macros used to define individual checks within an single unit test (e.g. defined by TEUCHOS_UNIT_TEST()).

NOTE: When a single check fails, the unit test is not aborted but instead will just print the failure to the local stream 'out' with the line number and continue on.

NOTE: The local unit test stream object 'out' will be written to and the variable 'success' will be set to 'false' if a test fails.

Macro Definition Documentation

#define ECHO (   statement)    TEUCHOS_ECHO( statement, out )

Echo the given statement before it is executed.

Definition at line 31 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_ASSERT (   v1)    TEUCHOS_TEST_ASSERT( v1, out, success )

Assert the given statement is true.

Definition at line 39 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_EQUALITY_CONST (   v1,
  v2 
)    TEUCHOS_TEST_EQUALITY_CONST( v1, v2, out, success )

Assert the equality of v1 and constant v2.

Examples:
ArrayRCP_test.cpp.

Definition at line 47 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_EQUALITY (   v1,
  v2 
)    TEUCHOS_TEST_EQUALITY( v1, v2, out, success )

Assert the equality of v1 and v2.

Definition at line 55 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_INEQUALITY_CONST (   v1,
  v2 
)    TEUCHOS_TEST_INEQUALITY_CONST( v1, v2, out, success )

Assert the inequality of v1 and constant v2.

Definition at line 63 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_INEQUALITY (   v1,
  v2 
)    TEUCHOS_TEST_INEQUALITY( v1, v2, out, success )

Assert the inequality of v1 and v2.

Definition at line 71 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_FLOATING_EQUALITY (   v1,
  v2,
  tol 
)    TEUCHOS_TEST_FLOATING_EQUALITY( v1, v2, tol, out, success )

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

Definition at line 80 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_ITER_EQUALITY (   iter1,
  iter2 
)    TEUCHOS_TEST_ITER_EQUALITY( iter1, iter2, out, success )

Assert that two iterators are equal.

Definition at line 88 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_ITER_INEQUALITY (   iter1,
  iter2 
)    TEUCHOS_TEST_ITER_INEQUALITY( iter1, iter2, out, success )

Assert that two iterators are NOT equal.

Definition at line 96 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_ARRAY_ELE_EQUALITY (   a,
  i,
  val 
)    TEUCHOS_TEST_ARRAY_ELE_EQUALITY( a, i, val, false, out, local_success )

Assert that a[i] == val.

Definition at line 104 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_ARRAY_ELE_INEQUALITY (   a,
  i,
  val 
)    TEUCHOS_TEST_ARRAY_ELE_INEQUALITY( a, i, val, false, out, local_success )

Assert that a[i] != val.

Definition at line 112 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_COMPARE (   v1,
  comp,
  v2 
)    TEUCHOS_TEST_COMPARE( v1, comp, v2, out, success )

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

Definition at line 120 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_COMPARE_CONST (   v1,
  comp,
  v2 
)    TEUCHOS_TEST_COMPARE_CONST( v1, comp, v2, out, success )

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

Definition at line 129 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_COMPARE_ARRAYS (   a1,
  a2 
)
Value:
{ \
const bool l_result = compareArrays(a1,#a1,a2,#a2,out); \
if (!l_result) success = false; \
}
bool compareArrays(const Array1 &a1, const std::string &a1_name, const Array2 &a2, const std::string &a2_name, Teuchos::FancyOStream &out)
Compare if two array objects are the same or not.

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

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

Examples:
ArrayRCP_test.cpp.

Definition at line 140 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_COMPARE_FLOATING_ARRAYS (   a1,
  a2,
  tol 
)
Value:
{ \
const bool result = compareFloatingArrays(a1,#a1,a2,#a2,tol,out); \
if (!result) success = false; \
}
bool compareFloatingArrays(const Array1 &a1, const std::string &a1_name, const Array2 &a2, const std::string &a2_name, const ScalarMag &tol, Teuchos::FancyOStream &out)
Compare if two array objects are the same or not up to a relative floating point precision.

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

Works for all 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 154 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_ABSOLUTE_COMPARE_FLOATING_ARRAYS (   a1,
  a2,
  tol 
)
Value:
{ \
const bool result = compareFloatingArraysAbsolute(a1,#a1,a2,#a2,tol,out); \
if (!result) success = false; \
}
bool compareFloatingArraysAbsolute(const Array1 &a1, const std::string &a1_name, const Array2 &a2, const std::string &a2_name, const ScalarMag &tol, Teuchos::FancyOStream &out)
Compare if two array objects are the same up to an absolute tolerance: elements a1[i] and a2[i] are c...

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

Works for all object types that support a1[i], a1.size(), a2[j], and a2.size(), but the element types of a1 and a2 must be the same and Teuchos::ScalarTraits must have a specialization for this element type.

Definition at line 168 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_THROW (   code,
  ExceptType 
)    TEUCHOS_TEST_THROW( code, ExceptType, out, success )

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

Definition at line 179 of file Teuchos_LocalTestingHelpers.hpp.

#define TEST_NOTHROW (   code)    TEUCHOS_TEST_NOTHROW( code, out, success )

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

Definition at line 187 of file Teuchos_LocalTestingHelpers.hpp.