TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
Testing tools

Detailed Description

Convenient tools for checking nda::basic_array and nda::basic_array_view objects with googletest.

Macros

#define EXPECT_ARRAY_EQ(X, Y)
 Macro that expects array_are_equal to return true.
 
#define EXPECT_ARRAY_NEAR(X, ...)
 Macro that expects array_are_close to return true.
 
#define EXPECT_ARRAY_ZERO(X)
 Macro that expects array_almost_zero to return true.
 
#define EXPECT_CLOSE(X, Y)
 Macro that expects generic_are_near to return true.
 
#define EXPECT_COMPLEX_NEAR(X, ...)
 Macro that expects complex_are_close to return true.
 
#define EXPECT_EQ_ARRAY(X, Y)
 Macro that expects array_are_equal to return true.
 

Functions

template<typename X >
::testing::AssertionResult array_almost_zero (X const &x)
 Check that an array/view is close to zero, i.e. that its largest absolute element is less than 1e-10.
 
template<typename X , typename Y >
::testing::AssertionResult array_are_close (X const &x, Y const &y, double precision=1.e-10)
 Check that two arrays/views are close, i.e. that they have the same shape and that the largest element of their absolute difference is less than a given precision.
 
template<typename X , typename Y >
::testing::AssertionResult array_are_equal (X const &x, Y const &y)
 Check that two arrays/views are equal, i.e. that they have the same shape and the same elements.
 
template<typename X , typename Y >
::testing::AssertionResult complex_are_close (X const &x, Y const &y, double precision=1.e-10)
 Check the absolute difference of two (complex) numbers.
 
template<typename X , typename Y >
::testing::AssertionResult generic_are_near (X const &x, Y const &y)
 Check that that two generic objects are close, i.e. that their absolute difference is less than 1e-12.
 

Function Documentation

◆ array_almost_zero()

template<typename X >
::testing::AssertionResult array_almost_zero ( X const & x)

#include <nda/gtest_tools.hpp>

Check that an array/view is close to zero, i.e. that its largest absolute element is less than 1e-10.

Template Parameters
XType of the array/view.
Parameters
xArray/View.
Returns
::testing::AssertionSuccess() if the absolute value of every element is less than 1e-10. ::testing::AssertionFailure() otherwise.

Definition at line 136 of file gtest_tools.hpp.

◆ array_are_close()

template<typename X , typename Y >
::testing::AssertionResult array_are_close ( X const & x,
Y const & y,
double precision = 1.e-10 )

#include <nda/gtest_tools.hpp>

Check that two arrays/views are close, i.e. that they have the same shape and that the largest element of their absolute difference is less than a given precision.

Template Parameters
XType of the first array/view.
YType of the second array/view.
Parameters
xFirst array/view.
ySecond array/view.
precisionRequired precision for the comparison to be considered successful.
Returns
::testing::AssertionSuccess() if the arrays/view have the same shape and largest element of their absolute difference is less than a given precision. ::testing::AssertionFailure() otherwise.

Definition at line 104 of file gtest_tools.hpp.

◆ array_are_equal()

template<typename X , typename Y >
::testing::AssertionResult array_are_equal ( X const & x,
Y const & y )

#include <nda/gtest_tools.hpp>

Check that two arrays/views are equal, i.e. that they have the same shape and the same elements.

Template Parameters
XType of the first array/view.
YType of the second array/view.
Parameters
xFirst array/view.
ySecond array/view.
Returns
::testing::AssertionSuccess() if the arrays/view have the same shape and the same elements, ::testing::AssertionFailure() otherwise.

Definition at line 75 of file gtest_tools.hpp.

◆ complex_are_close()

template<typename X , typename Y >
::testing::AssertionResult complex_are_close ( X const & x,
Y const & y,
double precision = 1.e-10 )

#include <nda/gtest_tools.hpp>

Check the absolute difference of two (complex) numbers.

Template Parameters
XType of the first number.
YType of the second number.
Parameters
xFirst number.
ySecond number.
precisionRequired precision for the comparison to be considered successful.
Returns
::testing::AssertionSuccess() if the absolute difference is less than the given precision, ::testing::AssertionFailure() otherwise.

Definition at line 53 of file gtest_tools.hpp.

◆ generic_are_near()

template<typename X , typename Y >
::testing::AssertionResult generic_are_near ( X const & x,
Y const & y )

#include <nda/gtest_tools.hpp>

Check that that two generic objects are close, i.e. that their absolute difference is less than 1e-12.

Template Parameters
XType of the first object.
YType of the second object.
Parameters
xFirst object.
ySecond object.
Returns
::testing::AssertionSuccess() if the absolute value of their difference is less than 1e-12. ::testing::AssertionFailure() otherwise.

Definition at line 161 of file gtest_tools.hpp.