unit_test_cx0 Subroutine

private subroutine unit_test_cx0(this, res, expected, tol, msg)

Type Bound

unit_test

Arguments

Type IntentOptional Attributes Name
class(unit_test), intent(inout) :: this
complex(kind=rk), intent(in) :: res
complex(kind=rk), intent(in) :: expected
real(kind=rk), intent(in), optional :: tol
character(len=*), intent(in), optional :: msg

Calls

proc~~unit_test_cx0~~CallsGraph proc~unit_test_cx0 forunittest::unit_test%unit_test_cx0 proc~print_msg forunittest::unit_test%print_msg proc~unit_test_cx0->proc~print_msg colorize colorize proc~print_msg->colorize

Called by

proc~~unit_test_cx0~~CalledByGraph proc~unit_test_cx0 forunittest::unit_test%unit_test_cx0 none~check forunittest::unit_test%check none~check->proc~unit_test_cx0 program~demo demo program~demo->none~check program~test test program~test->none~check

Source Code

   subroutine unit_test_cx0(this, res, expected, tol, msg)
      class(unit_test), intent(inout) :: this
      complex(rk), intent(in) :: res, expected
      real(rk), intent(in), optional :: tol
      character(*), intent(in), optional :: msg
      logical :: condition
      real(rk) :: rel_err

      if (present(msg)) then
         this%msg = msg
      else
         this%msg = 'forunittest'
      end if

      if (abs(expected)<tiny(0.0_rk)) then
         rel_err = abs(res-expected)
      else
         rel_err = abs(res-expected)/abs(expected)
      end if

      if (present(tol)) then
         condition = rel_err < tol
      else
         condition = rel_err == 0.0_rk
      end if

      call this%print_msg(condition)
   end subroutine unit_test_cx0