naturalFRUIT provides several assert methods to check for and report failures. The following list contains variants of the most commonly used formats. Although only the assert_equal, assert_true and assert_identical methods are described here, analogous formats exist for the assert_not_equal, assert_false and assert_not_identical methods.
assert_equal| Syntax | Returns true if | Underlying subroutine |
|---|---|---|
assert_equal(logical a, logical b) | a == b | assert_eq_logical_ |
assert_equal(string a, string b) | a == b | assert_eq_string_ |
assert_equal(int a, int b) | a == b | assert_eq_int_ |
assert_equal(real a, real b) | abs(a-b) < eps | assert_eq_real_ |
assert_equal(real a, real b, real tol) | abs(a-b) < tol | assert_eq_real_ |
assert_equal(real(dp) a, real(dp) b) | abs(a-b) < eps | assert_eq_double_ |
assert_equal(real(dp) a, real(dp) b, real(dp) tol) | abs(a-b) < tol | assert_eq_double_ |
assert_equal(complex a, complex b) | abs(a-b) < (eps,eps) | assert_eq_complex_ |
assert_equal(complex a, complex b, tol) | abs(a-b) < (tol,tol) | assert_eq_complex_ |
assert_equal(complex(dp) a, complex(dp) b) | abs(a-b) < (eps,eps) | assert_eq_complex_double_ |
assert_equal(complex(dp) a, complex(dp) b, real(dp) tol) | abs(a-b) < (tol,tol) | assert_eq_complex_double_ |
assert_true| Syntax | Returns true if | Underlying subroutine |
|---|---|---|
assert_true(logical a) | a == .true. | assert_true |
assert_identical| Syntax | Returns true if | Underlying subroutine |
|---|---|---|
assert_identical(string filename1, string filename2) | contents are same | assert_identical |
All the assert methods accept two optional arguments message and status.
message, if specified, is used as the error message on failure.
status, if present, supresses general test case behaviour like printing of success and failure messages, and the boolean variable provided to the status specifier returns .true. or .false. depending on assert sucess or failure.
Additionally, all assert subroutines that handle int, real, real(dp), complex, and complex(dp) can also accept one and two dimensional arrays as input arguments. An element-wise check is performed in these cases.