9797! > For an example setup checkout the ``test/`` directory in this project.
9898module testdrive
9999 use , intrinsic :: iso_fortran_env, only : error_unit
100+ use , intrinsic :: ieee_arithmetic, only : ieee_is_nan
100101 implicit none
101102 private
102103
@@ -155,6 +156,8 @@ module testdrive
155156 module procedure :: check_logical
156157 module procedure :: check_float_sp
157158 module procedure :: check_float_dp
159+ module procedure :: check_exceptional_sp
160+ module procedure :: check_exceptional_dp
158161 module procedure :: check_int_i1
159162 module procedure :: check_int_i2
160163 module procedure :: check_int_i4
@@ -501,6 +504,9 @@ subroutine check_float_dp(error, actual, expected, message, more, thr, rel)
501504 logical :: relative
502505 real (dp) :: diff, threshold
503506
507+ call check(error, actual, message, more)
508+ if (allocated (error)) return
509+
504510 if (present (thr)) then
505511 threshold = thr
506512 else
@@ -542,6 +548,31 @@ subroutine check_float_dp(error, actual, expected, message, more, thr, rel)
542548end subroutine check_float_dp
543549
544550
551+ subroutine check_exceptional_dp (error , actual , message , more )
552+
553+ ! > Error handling
554+ type (error_type), allocatable , intent (out ) :: error
555+
556+ ! > Found floating point value
557+ real (dp), intent (in ) :: actual
558+
559+ ! > A detailed message describing the error
560+ character (len=* ), intent (in ), optional :: message
561+
562+ ! > Another line of error message
563+ character (len=* ), intent (in ), optional :: more
564+
565+ if (ieee_is_nan(actual)) then
566+ if (present (message)) then
567+ call test_failed(error, message, more)
568+ else
569+ call test_failed(error, " Exceptional value 'not a number' found" , more)
570+ end if
571+ end if
572+
573+ end subroutine check_exceptional_dp
574+
575+
545576subroutine check_float_sp (error , actual , expected , message , more , thr , rel )
546577
547578 ! > Error handling
@@ -568,6 +599,9 @@ subroutine check_float_sp(error, actual, expected, message, more, thr, rel)
568599 logical :: relative
569600 real (sp) :: diff, threshold
570601
602+ call check(error, actual, message, more)
603+ if (allocated (error)) return
604+
571605 if (present (thr)) then
572606 threshold = thr
573607 else
@@ -609,6 +643,31 @@ subroutine check_float_sp(error, actual, expected, message, more, thr, rel)
609643end subroutine check_float_sp
610644
611645
646+ subroutine check_exceptional_sp (error , actual , message , more )
647+
648+ ! > Error handling
649+ type (error_type), allocatable , intent (out ) :: error
650+
651+ ! > Found floating point value
652+ real (sp), intent (in ) :: actual
653+
654+ ! > A detailed message describing the error
655+ character (len=* ), intent (in ), optional :: message
656+
657+ ! > Another line of error message
658+ character (len=* ), intent (in ), optional :: more
659+
660+ if (ieee_is_nan(actual)) then
661+ if (present (message)) then
662+ call test_failed(error, message, more)
663+ else
664+ call test_failed(error, " Exceptional value 'not a number' found" , more)
665+ end if
666+ end if
667+
668+ end subroutine check_exceptional_sp
669+
670+
612671subroutine check_int_i1 (error , actual , expected , message , more )
613672
614673 ! > Error handling
0 commit comments