GRASP rci-qed
Public Member Functions | List of all members
grasptest_testing::test_isequal Interface Reference

Public Member Functions

subroutine test_isequal_real64 (test_passed, which, a, b, relative_tolerance)
 Tests if two floating point values are the same withing the specified relative tolerance. More...
 
subroutine test_isequal_logical (test_passed, which, a, b)
 Tests if two logical values are equal. More...
 
subroutine test_isequal_integer (test_passed, which, a, b)
 Tests if two integer values are equal. More...
 

Member Function/Subroutine Documentation

◆ test_isequal_integer()

subroutine grasptest_testing::test_isequal::test_isequal_integer ( logical, intent(inout)  test_passed,
character(*), intent(in)  which,
integer, intent(in)  a,
integer, intent(in)  b 
)

Tests if two integer values are equal.

◆ test_isequal_logical()

subroutine grasptest_testing::test_isequal::test_isequal_logical ( logical, intent(inout)  test_passed,
character(*), intent(in)  which,
logical, intent(in)  a,
logical, intent(in)  b 
)

Tests if two logical values are equal.

◆ test_isequal_real64()

subroutine grasptest_testing::test_isequal::test_isequal_real64 ( logical, intent(inout)  test_passed,
character(*), intent(in)  which,
real(real64), intent(in)  a,
real(real64), intent(in)  b,
real(real64), intent(in)  relative_tolerance 
)

Tests if two floating point values are the same withing the specified relative tolerance.

Specifically, it tests that

\[ \frac{|a-b|}{\max(|a|, |b|)} < \sigma \]

where \(\sigma\) is the specified relative tolerance.

If the test fails, test_passed gets set to .false., but the value is unchanged if the tests pass. This allows for the pattern where the test function is called multiple times before checking if any of the tests failed:

call test_isequal(success, "T1", a1, b1, rtol)
call test_isequal(success, "T2", a2, b2, rtol)
if(.not.success) then
print *, "Test failures occurred."
endif

On failure, a message gets printed into the standard output that a test failed, which also includes the which string, allowing for the failed test to be identified easily.

Parameters
test_passedGets set to .false. if the test fails, and is left unchanged otherwise.
whichA string that identifies the test.
a,bValues to be compared.
relative_toleranceThe relative tolerance \(\sigma\).

The documentation for this interface was generated from the following file: