115 '$Id: UnitTest_Define.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 116 INTEGER,
PARAMETER ::
sl = 512
117 INTEGER,
PARAMETER ::
cr = 13
118 INTEGER,
PARAMETER ::
lf = 10
119 CHARACTER(2),
PARAMETER ::
crlf = achar(
cr)//achar(
lf)
120 CHARACTER(*),
PARAMETER ::
rfmt =
'es25.18' 153 CHARACTER(SL) :: title =
'' 154 CHARACTER(SL) :: caller =
'' 158 CHARACTER(SL) ::
Procedure =
'' 159 CHARACTER(SL) :: message =
'' 161 LOGICAL :: test_result = .true.
163 INTEGER :: n_tests = 0
164 INTEGER :: n_passed_tests = 0
165 INTEGER :: n_failed_tests = 0
167 INTEGER :: n_alltests = 0
168 INTEGER :: n_passed_alltests = 0
169 INTEGER :: n_failed_alltests = 0
221 LOGICAL,
OPTIONAL,
INTENT(IN) :: verbose
223 CHARACTER(*),
PARAMETER :: procedure_name =
'UnitTest_Init' 225 LOGICAL :: local_verbose
229 IF (
PRESENT(verbose) ) local_verbose = verbose
234 verbose = local_verbose, &
236 Procedure = procedure_name, &
238 n_passed_tests = 0, &
239 n_failed_tests = 0, &
241 n_passed_alltests = 0, &
242 n_failed_alltests = 0 )
302 CHARACTER(*) ,
INTENT(IN) :: title
303 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: caller
304 LOGICAL,
OPTIONAL,
INTENT(IN) :: verbose
306 CHARACTER(*),
PARAMETER :: procedure_name =
'UnitTest_Setup' 308 CHARACTER(SL) :: local_caller
309 LOGICAL :: local_verbose
310 CHARACTER(SL) :: message
314 IF (
PRESENT(caller) ) local_caller =
'; CALLER: '//trim(adjustl(caller))
316 IF (
PRESENT(verbose) ) local_verbose = verbose
319 message = trim(title)//trim(local_caller)
324 title = adjustl(title), &
325 caller = local_caller , &
326 verbose = local_verbose , &
328 Procedure = procedure_name, &
331 n_passed_tests = 0, &
366 CHARACTER(*),
PARAMETER :: procedure_name =
'UnitTest_Report' 369 INTEGER :: n_passed_tests
370 INTEGER :: n_failed_tests
371 CHARACTER(SL) :: message
372 CHARACTER(SL) :: attention
373 CHARACTER(SL) :: colour
377 n_tests = n_tests , &
378 n_passed_tests = n_passed_tests, &
379 n_failed_tests = n_failed_tests )
384 IF ( n_failed_tests /= 0 )
THEN 386 attention =
' <----<<< **WARNING**' 391 '(a,a,3x,"Passed ",i0," of ",i0," tests", & 392 &a,3x,"Failed ",i0," of ",i0," tests",a,a)') &
393 trim(colour),
crlf, &
394 n_passed_tests, n_tests, &
396 n_failed_tests, n_tests, &
401 Procedure = procedure_name, &
436 CHARACTER(*),
PARAMETER :: procedure_name =
'UnitTest_Summary' 438 INTEGER :: n_alltests
439 INTEGER :: n_passed_alltests
440 INTEGER :: n_failed_alltests
441 CHARACTER(SL) :: message
442 CHARACTER(SL) :: attention
443 CHARACTER(SL) :: colour
448 n_alltests = n_alltests , &
449 n_passed_alltests = n_passed_alltests, &
450 n_failed_alltests = n_failed_alltests )
455 IF ( n_failed_alltests /= 0 )
THEN 457 attention =
' <----<<< **WARNING**' 462 '(a,a,1x,"Passed ",i0," of ",i0," total tests",& 463 &a,1x,"Failed ",i0," of ",i0," total tests",a,a)') &
464 trim(colour),
crlf, &
465 n_passed_alltests, n_alltests, &
467 n_failed_alltests, n_alltests, &
472 Procedure = procedure_name, &
656 LOGICAL,
INTENT(IN) ::
test 658 CHARACTER(*),
PARAMETER :: procedure_name =
'UnitTest_Assert' 661 CHARACTER(SL) :: message
669 verbose = verbose .OR. (.NOT.
test)
683 Procedure = procedure_name, &
736 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
737 INTEGER(Byte),
INTENT(IN) :: Expected, Actual
739 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Byte)]' 743 CHARACTER(SL) :: Message
747 test = (expected == actual)
752 verbose = verbose .OR. (.NOT.
test)
763 WRITE( message,
'("Expected ",i0," and got ",i0)') expected, actual
767 Procedure = procedure_name, &
775 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
776 INTEGER(Byte),
INTENT(IN) :: Expected(:), Actual(:)
778 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Byte)]' 781 CHARACTER(SL) :: Message
784 isize =
SIZE(expected)
785 IF (
SIZE(actual) /= isize )
THEN 788 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
793 Procedure = procedure_name, &
808 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
809 INTEGER(Byte),
INTENT(IN) :: Expected(:,:), Actual(:,:)
811 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Byte)]' 813 INTEGER :: i, j, isize, jsize
814 CHARACTER(SL) :: Message
817 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
818 IF (
SIZE(actual,dim=1) /= isize .OR. &
819 SIZE(actual,dim=2) /= jsize )
THEN 822 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
824 SIZE(actual,dim=1),
SIZE(actual,dim=2)
828 Procedure = procedure_name, &
845 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
846 INTEGER(Short),
INTENT(IN) :: Expected, Actual
848 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Short)]' 852 CHARACTER(SL) :: Message
856 test = (expected == actual)
861 verbose = verbose .OR. (.NOT.
test)
872 WRITE( message,
'("Expected ",i0," and got ",i0)') expected, actual
876 Procedure = procedure_name, &
884 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
885 INTEGER(Short),
INTENT(IN) :: Expected(:), Actual(:)
887 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Short)]' 890 CHARACTER(SL) :: Message
893 isize =
SIZE(expected)
894 IF (
SIZE(actual) /= isize )
THEN 897 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
902 Procedure = procedure_name, &
917 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
918 INTEGER(Short),
INTENT(IN) :: Expected(:,:), Actual(:,:)
920 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Short)]' 922 INTEGER :: i, j, isize, jsize
923 CHARACTER(SL) :: Message
926 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
927 IF (
SIZE(actual,dim=1) /= isize .OR. &
928 SIZE(actual,dim=2) /= jsize )
THEN 931 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
933 SIZE(actual,dim=1),
SIZE(actual,dim=2)
937 Procedure = procedure_name, &
954 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
955 INTEGER(Long),
INTENT(IN) :: Expected, Actual
957 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Long)]' 961 CHARACTER(SL) :: Message
965 test = (expected == actual)
970 verbose = verbose .OR. (.NOT.
test)
981 WRITE( message,
'("Expected ",i0," and got ",i0)') expected, actual
985 Procedure = procedure_name, &
993 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
994 INTEGER(Long),
INTENT(IN) :: Expected(:), Actual(:)
996 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Long)]' 999 CHARACTER(SL) :: Message
1002 isize =
SIZE(expected)
1003 IF (
SIZE(actual) /= isize )
THEN 1006 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
1011 Procedure = procedure_name, &
1026 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1027 INTEGER(Long),
INTENT(IN) :: Expected(:,:), Actual(:,:)
1029 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[INTEGER(Long)]' 1031 INTEGER :: i, j, isize, jsize
1032 CHARACTER(SL) :: Message
1035 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1036 IF (
SIZE(actual,dim=1) /= isize .OR. &
1037 SIZE(actual,dim=2) /= jsize )
THEN 1040 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
1042 SIZE(actual,dim=1),
SIZE(actual,dim=2)
1046 Procedure = procedure_name, &
1063 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1064 REAL(Single),
INTENT(IN) :: Expected, Actual
1066 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[REAL(Single)]' 1070 CHARACTER(SL) :: Message
1074 test = (expected .equalto. actual)
1079 verbose = verbose .OR. (.NOT.
test)
1091 '(a,7x,"Expected: ",'//
rfmt//
',a,& 1092 &7x,"And got: ",'//
rfmt//
')') &
1097 Procedure = procedure_name, &
1105 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1106 REAL(Single),
INTENT(IN) :: Expected(:), Actual(:)
1108 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[REAL(Single)]' 1111 CHARACTER(SL) :: Message
1114 isize =
SIZE(expected)
1115 IF (
SIZE(actual) /= isize )
THEN 1118 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
1123 Procedure = procedure_name, &
1138 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1139 REAL(Single),
INTENT(IN) :: Expected(:,:), Actual(:,:)
1141 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[REAL(Single)]' 1143 INTEGER :: i, j, isize, jsize
1144 CHARACTER(SL) :: Message
1147 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1148 IF (
SIZE(actual,dim=1) /= isize .OR. &
1149 SIZE(actual,dim=2) /= jsize )
THEN 1152 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
1154 SIZE(actual,dim=1),
SIZE(actual,dim=2)
1158 Procedure = procedure_name, &
1175 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1176 REAL(Double),
INTENT(IN) :: Expected, Actual
1178 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[REAL(Double)]' 1182 CHARACTER(SL) :: Message
1186 test = (expected .equalto. actual)
1191 verbose = verbose .OR. (.NOT.
test)
1203 '(a,7x,"Expected: ",'//
rfmt//
',a,& 1204 &7x,"And got: ",'//
rfmt//
')') &
1209 Procedure = procedure_name, &
1217 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1218 REAL(Double),
INTENT(IN) :: Expected(:), Actual(:)
1220 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[REAL(Double)]' 1223 CHARACTER(SL) :: Message
1226 isize =
SIZE(expected)
1227 IF (
SIZE(actual) /= isize )
THEN 1230 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
1235 Procedure = procedure_name, &
1250 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1251 REAL(Double),
INTENT(IN) :: Expected(:,:), Actual(:,:)
1253 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[REAL(Double)]' 1255 INTEGER :: i, j, isize, jsize
1256 CHARACTER(SL) :: Message
1259 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1260 IF (
SIZE(actual,dim=1) /= isize .OR. &
1261 SIZE(actual,dim=2) /= jsize )
THEN 1264 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
1266 SIZE(actual,dim=1),
SIZE(actual,dim=2)
1270 Procedure = procedure_name, &
1287 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1288 COMPLEX(Single),
INTENT(IN) :: Expected, Actual
1290 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[COMPLEX(Single)]' 1294 CHARACTER(SL) :: Message
1298 test = (expected .equalto. actual)
1303 verbose = verbose .OR. (.NOT.
test)
1315 '(a,7x,"Expected: ",'//
zfmt//
',a,& 1316 &7x,"And got: ",'//
zfmt//
')') &
1321 Procedure = procedure_name, &
1329 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1330 COMPLEX(Single),
INTENT(IN) :: Expected(:), Actual(:)
1332 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[COMPLEX(Single)]' 1335 CHARACTER(SL) :: Message
1338 isize =
SIZE(expected)
1339 IF (
SIZE(actual) /= isize )
THEN 1342 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
1347 Procedure = procedure_name, &
1362 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1363 COMPLEX(Single),
INTENT(IN) :: Expected(:,:), Actual(:,:)
1365 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[COMPLEX(Single)]' 1367 INTEGER :: i, j, isize, jsize
1368 CHARACTER(SL) :: Message
1371 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1372 IF (
SIZE(actual,dim=1) /= isize .OR. &
1373 SIZE(actual,dim=2) /= jsize )
THEN 1376 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
1378 SIZE(actual,dim=1),
SIZE(actual,dim=2)
1382 Procedure = procedure_name, &
1399 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1400 COMPLEX(Double),
INTENT(IN) :: Expected, Actual
1402 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[COMPLEX(Double)]' 1406 CHARACTER(SL) :: Message
1410 test = (expected .equalto. actual)
1415 verbose = verbose .OR. (.NOT.
test)
1427 '(a,7x,"Expected: ",'//
zfmt//
',a,& 1428 &7x,"And got: ",'//
zfmt//
')') &
1433 Procedure = procedure_name, &
1441 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1442 COMPLEX(Double),
INTENT(IN) :: Expected(:), Actual(:)
1444 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[COMPLEX(Double)]' 1447 CHARACTER(SL) :: Message
1450 isize =
SIZE(expected)
1451 IF (
SIZE(actual) /= isize )
THEN 1454 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
1459 Procedure = procedure_name, &
1474 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1475 COMPLEX(Double),
INTENT(IN) :: Expected(:,:), Actual(:,:)
1477 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[COMPLEX(Double)]' 1479 INTEGER :: i, j, isize, jsize
1480 CHARACTER(SL) :: Message
1483 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1484 IF (
SIZE(actual,dim=1) /= isize .OR. &
1485 SIZE(actual,dim=2) /= jsize )
THEN 1488 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
1490 SIZE(actual,dim=1),
SIZE(actual,dim=2)
1494 Procedure = procedure_name, &
1511 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1512 CHARACTER(*),
INTENT(IN) :: Expected, Actual
1514 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[CHARACTER]' 1518 CHARACTER(SL) :: Message
1522 test = (expected == actual)
1527 verbose = verbose .OR. (.NOT.
test)
1538 WRITE( message,
'("Expected >",a,"< and got >",a,"<")') expected, actual
1542 Procedure = procedure_name, &
1550 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1551 CHARACTER(*),
INTENT(IN) :: Expected(:), Actual(:)
1553 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[CHARACTER]' 1556 CHARACTER(SL) :: Message
1559 isize =
SIZE(expected)
1560 IF (
SIZE(actual) /= isize )
THEN 1563 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0)') &
1568 Procedure = procedure_name, &
1583 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1584 CHARACTER(*),
INTENT(IN) :: Expected(:,:), Actual(:,:)
1586 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqual[CHARACTER]' 1588 INTEGER :: i, j, isize, jsize
1589 CHARACTER(SL) :: Message
1592 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1593 IF (
SIZE(actual,dim=1) /= isize .OR. &
1594 SIZE(actual,dim=2) /= jsize )
THEN 1597 '("Array sizes are diffferent -- Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,")")') &
1599 SIZE(actual,dim=1),
SIZE(actual,dim=2)
1603 Procedure = procedure_name, &
1692 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1693 REAL(Single),
INTENT(IN) :: Expected, Actual, Tolerance
1694 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
1696 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[REAL(Single)]' 1701 CHARACTER(SL) :: Message
1707 IF (
PRESENT(epsilon_scale) )
THEN 1708 IF ( epsilon_scale ) tol = epsilon(expected) *
get_multiplier( expected )
1711 test = (abs(expected-actual) < tol)
1716 verbose = verbose .OR. (.NOT.
test)
1728 '(a,7x,"Expected: ",'//
rfmt//
',a,& 1729 &7x,"To within: ",'//
rfmt//
',a,& 1730 &7x,"And got: ",'//
rfmt//
',a,& 1731 &7x,"|Difference|: ",'//
rfmt//
')') &
1736 Procedure = procedure_name, &
1749 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1750 REAL(Single),
INTENT(IN) :: Expected(:), Actual(:), Tolerance(:)
1751 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
1753 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[REAL(Single)]' 1756 CHARACTER(SL) :: Message
1759 isize =
SIZE(expected)
1760 IF (
SIZE(actual) /= isize .OR. &
1764 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0,"; Tolerance:",i0)') &
1769 Procedure = procedure_name, &
1782 epsilon_scale = epsilon_scale )
1794 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1795 REAL(Single),
INTENT(IN) :: Expected(:,:), Actual(:,:), Tolerance(:,:)
1796 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
1798 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[REAL(Single)]' 1800 INTEGER :: i, j, isize, jsize
1801 CHARACTER(SL) :: Message
1804 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1805 IF (
SIZE(actual,dim=1) /= isize .OR. &
1806 SIZE(actual,dim=2) /= jsize .OR. &
1811 '("Array sizes are diffferent -- ",& 1812 &"Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,"); Tolerance:(",i0,",",i0,")")') &
1814 SIZE(actual,dim=1),
SIZE(actual,dim=2), &
1819 Procedure = procedure_name, &
1833 epsilon_scale = epsilon_scale )
1846 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1847 REAL(Double),
INTENT(IN) :: Expected, Actual, Tolerance
1848 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
1850 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[REAL(Double)]' 1855 CHARACTER(SL) :: Message
1861 IF (
PRESENT(epsilon_scale) )
THEN 1862 IF ( epsilon_scale ) tol = epsilon(expected) *
get_multiplier( expected )
1865 test = (abs(expected-actual) < tol)
1870 verbose = verbose .OR. (.NOT.
test)
1882 '(a,7x,"Expected: ",'//
rfmt//
',a,& 1883 &7x,"To within: ",'//
rfmt//
',a,& 1884 &7x,"And got: ",'//
rfmt//
',a,& 1885 &7x,"|Difference|: ",'//
rfmt//
')') &
1890 Procedure = procedure_name, &
1903 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1904 REAL(Double),
INTENT(IN) :: Expected(:), Actual(:), Tolerance(:)
1905 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
1907 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[REAL(Double)]' 1910 CHARACTER(SL) :: Message
1913 isize =
SIZE(expected)
1914 IF (
SIZE(actual) /= isize .OR. &
1918 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0,"; Tolerance:",i0)') &
1923 Procedure = procedure_name, &
1936 epsilon_scale = epsilon_scale )
1948 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
1949 REAL(Double),
INTENT(IN) :: Expected(:,:), Actual(:,:), Tolerance(:,:)
1950 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
1952 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[REAL(Double)]' 1954 INTEGER :: i, j, isize, jsize
1955 CHARACTER(SL) :: Message
1958 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
1959 IF (
SIZE(actual,dim=1) /= isize .OR. &
1960 SIZE(actual,dim=2) /= jsize .OR. &
1965 '("Array sizes are diffferent -- ",& 1966 &"Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,"); Tolerance:(",i0,",",i0,")")') &
1968 SIZE(actual,dim=1),
SIZE(actual,dim=2), &
1973 Procedure = procedure_name, &
1987 epsilon_scale = epsilon_scale )
2000 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2001 COMPLEX(Single),
INTENT(IN) :: Expected, Actual, Tolerance
2002 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
2004 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[COMPLEX(Single)]' 2006 REAL(Single) :: tolr, toli
2007 REAL(Single) :: zr, zi
2008 REAL(Single) :: dzr, dzi
2011 CHARACTER(SL) :: Message
2015 zr =
REAL(Expected,Single)
2016 zi = aimag(expected)
2018 tolr =
REAL(Tolerance,Single)
2021 IF (
PRESENT(epsilon_scale) )
THEN 2022 IF ( epsilon_scale )
THEN 2028 dzr = abs(zr -
REAL(Actual,Single))
2029 dzi = abs(zi - aimag(actual))
2030 test = (dzr < tolr) .AND. (dzi < toli)
2035 verbose = verbose .OR. (.NOT.
test)
2047 '(a,7x,"Expected: ",'//
zfmt//
',a,& 2048 &7x,"To within: ",'//
zfmt//
',a,& 2049 &7x,"And got: ",'//
zfmt//
',a,& 2050 &7x,"|Difference|: ",'//
zfmt//
')') &
2051 crlf, expected,
crlf, cmplx(tolr,toli,single),
crlf, actual,
crlf, dzr, dzi
2055 Procedure = procedure_name, &
2068 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2069 COMPLEX(Single),
INTENT(IN) :: Expected(:), Actual(:), Tolerance(:)
2070 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
2072 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[COMPLEX(Single)]' 2075 CHARACTER(SL) :: Message
2078 isize =
SIZE(expected)
2079 IF (
SIZE(actual) /= isize .OR. &
2083 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0,"; Tolerance:",i0)') &
2088 Procedure = procedure_name, &
2101 epsilon_scale = epsilon_scale )
2113 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2114 COMPLEX(Single),
INTENT(IN) :: Expected(:,:), Actual(:,:), Tolerance(:,:)
2115 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
2117 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[COMPLEX(Single)]' 2119 INTEGER :: i, j, isize, jsize
2120 CHARACTER(SL) :: Message
2123 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
2124 IF (
SIZE(actual,dim=1) /= isize .OR. &
2125 SIZE(actual,dim=2) /= jsize .OR. &
2130 '("Array sizes are diffferent -- ",& 2131 &"Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,"); Tolerance:(",i0,",",i0,")")') &
2133 SIZE(actual,dim=1),
SIZE(actual,dim=2), &
2138 Procedure = procedure_name, &
2152 epsilon_scale = epsilon_scale )
2165 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2166 COMPLEX(Double),
INTENT(IN) :: Expected, Actual, Tolerance
2167 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
2169 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[COMPLEX(Double)]' 2171 REAL(Double) :: tolr, toli
2172 REAL(Double) :: zr, zi
2173 REAL(Double) :: dzr, dzi
2176 CHARACTER(SL) :: Message
2180 zr =
REAL(Expected,Double)
2181 zi = aimag(expected)
2183 tolr =
REAL(Tolerance,Double)
2186 IF (
PRESENT(epsilon_scale) )
THEN 2187 IF ( epsilon_scale )
THEN 2193 dzr = abs(zr -
REAL(Actual,Double))
2194 dzi = abs(zi - aimag(actual))
2195 test = (dzr < tolr) .AND. (dzi < toli)
2200 verbose = verbose .OR. (.NOT.
test)
2212 '(a,7x,"Expected: ",'//
zfmt//
',a,& 2213 &7x,"To within: ",'//
zfmt//
',a,& 2214 &7x,"And got: ",'//
zfmt//
',a,& 2215 &7x,"|Difference|: ",'//
zfmt//
')') &
2216 crlf, expected,
crlf, cmplx(tolr,toli,double),
crlf, actual,
crlf, dzr, dzi
2220 Procedure = procedure_name, &
2233 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2234 COMPLEX(Double),
INTENT(IN) :: Expected(:), Actual(:), Tolerance(:)
2235 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
2237 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[COMPLEX(Double)]' 2240 CHARACTER(SL) :: Message
2243 isize =
SIZE(expected)
2244 IF (
SIZE(actual) /= isize .OR. &
2248 '("Array sizes are diffferent -- Expected:",i0,"; Actual:",i0,"; Tolerance:",i0)') &
2253 Procedure = procedure_name, &
2266 epsilon_scale = epsilon_scale )
2278 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2279 COMPLEX(Double),
INTENT(IN) :: Expected(:,:), Actual(:,:), Tolerance(:,:)
2280 LOGICAL,
OPTIONAL,
INTENT(IN) :: Epsilon_Scale
2282 CHARACTER(*),
PARAMETER :: PROCEDURE_NAME =
'UnitTest_IsEqualWithin[COMPLEX(Double)]' 2284 INTEGER :: i, j, isize, jsize
2285 CHARACTER(SL) :: Message
2288 isize =
SIZE(expected,dim=1); jsize =
SIZE(expected,dim=2)
2289 IF (
SIZE(actual,dim=1) /= isize .OR. &
2290 SIZE(actual,dim=2) /= jsize .OR. &
2295 '("Array sizes are diffferent -- ",& 2296 &"Expected:(",i0,",",i0,"); Actual:(",i0,",",i0,"); Tolerance:(",i0,",",i0,")")') &
2298 SIZE(actual,dim=1),
SIZE(actual,dim=2), &
2303 Procedure = procedure_name, &
2317 epsilon_scale = epsilon_scale )
2347 CHARACTER(*),
INTENT(OUT) :: id
2498 UnitTest , & ! Object
2499 Verbose , & ! Optional input
2500 Title , & ! Optional input
2501 Caller , & ! Optional input
2502 Level , & ! Optional input
2503 Procedure , & ! Optional input
2504 Message , & ! Optional input
2505 Test_Result , & ! Optional input
2506 n_Tests , & ! Optional input
2507 n_Passed_Tests , & ! Optional input
2508 n_Failed_Tests , & ! Optional input
2509 n_AllTests , & ! Optional input
2510 n_Passed_AllTests, & ! Optional input
2514 LOGICAL ,
OPTIONAL,
INTENT(IN) :: verbose
2515 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: title
2516 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: caller
2517 INTEGER ,
OPTIONAL,
INTENT(IN) :: level
2518 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: procedure
2519 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message
2520 LOGICAL ,
OPTIONAL,
INTENT(IN) :: test_result
2521 INTEGER ,
OPTIONAL,
INTENT(IN) :: n_tests
2522 INTEGER ,
OPTIONAL,
INTENT(IN) :: n_passed_tests
2523 INTEGER ,
OPTIONAL,
INTENT(IN) :: n_failed_tests
2524 INTEGER ,
OPTIONAL,
INTENT(IN) :: n_alltests
2525 INTEGER ,
OPTIONAL,
INTENT(IN) :: n_passed_alltests
2526 INTEGER ,
OPTIONAL,
INTENT(IN) :: n_failed_alltests
2528 IF (
PRESENT(verbose ) ) unittest%Verbose = verbose
2529 IF (
PRESENT(title ) ) unittest%Title = title
2530 IF (
PRESENT(caller ) ) unittest%Caller = caller
2531 IF (
PRESENT(level ) ) unittest%Level = level
2532 IF (
PRESENT(
Procedure ) ) unittest%
Procedure = procedure
2533 IF (
PRESENT(message ) ) unittest%Message = message
2534 IF (
PRESENT(test_result ) ) unittest%Test_Result = test_result
2535 IF (
PRESENT(n_tests ) ) unittest%n_Tests = n_tests
2536 IF (
PRESENT(n_passed_tests ) ) unittest%n_Passed_Tests = n_passed_tests
2537 IF (
PRESENT(n_failed_tests ) ) unittest%n_Failed_Tests = n_failed_tests
2538 IF (
PRESENT(n_alltests ) ) unittest%n_AllTests = n_alltests
2539 IF (
PRESENT(n_passed_alltests) ) unittest%n_Passed_AllTests = n_passed_alltests
2540 IF (
PRESENT(n_failed_alltests) ) unittest%n_Failed_AllTests = n_failed_alltests
2678 UnitTest , & ! Object
2679 Verbose , & ! Optional output
2680 Title , & ! Optional output
2681 Caller , & ! Optional output
2682 Level , & ! Optional output
2683 Procedure , & ! Optional output
2684 Message , & ! Optional output
2685 Test_Result , & ! Optional output
2686 n_Tests , & ! Optional output
2687 n_Passed_Tests , & ! Optional output
2688 n_Failed_Tests , & ! Optional output
2689 n_AllTests , & ! Optional output
2690 n_Passed_AllTests, & ! Optional output
2694 LOGICAL ,
OPTIONAL,
INTENT(OUT) :: verbose
2695 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: title
2696 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: caller
2697 INTEGER ,
OPTIONAL,
INTENT(OUT) :: level
2698 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: procedure
2699 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: message
2700 LOGICAL ,
OPTIONAL,
INTENT(OUT) :: test_result
2701 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_tests
2702 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_passed_tests
2703 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_failed_tests
2704 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_alltests
2705 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_passed_alltests
2706 INTEGER ,
OPTIONAL,
INTENT(OUT) :: n_failed_alltests
2708 IF (
PRESENT(verbose ) ) verbose = unittest%Verbose
2709 IF (
PRESENT(title ) ) title = unittest%Title
2710 IF (
PRESENT(caller ) ) caller = unittest%Caller
2711 IF (
PRESENT(level ) ) level = unittest%Level
2712 IF (
PRESENT(
Procedure ) )
Procedure = unittest%Procedure
2713 IF (
PRESENT(message ) ) message = unittest%Message
2714 IF (
PRESENT(test_result ) ) test_result = unittest%Test_Result
2715 IF (
PRESENT(n_tests ) ) n_tests = unittest%n_Tests
2716 IF (
PRESENT(n_passed_tests ) ) n_passed_tests = unittest%n_Passed_Tests
2717 IF (
PRESENT(n_failed_tests ) ) n_failed_tests = unittest%n_Failed_Tests
2718 IF (
PRESENT(n_alltests ) ) n_alltests = unittest%n_AllTests
2719 IF (
PRESENT(n_passed_alltests) ) n_passed_alltests = unittest%n_Passed_AllTests
2720 IF (
PRESENT(n_failed_alltests) ) n_failed_alltests = unittest%n_Failed_AllTests
2746 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2748 INTEGER :: n_Passed_Tests, n_Passed_AllTests
2757 n_passed_tests = n_passed_tests, &
2758 n_passed_alltests = n_passed_alltests )
2760 n_passed_tests = n_passed_tests + 1
2761 n_passed_alltests = n_passed_alltests + 1
2765 test_result = .true., &
2766 n_passed_tests = n_passed_tests, &
2767 n_passed_alltests = n_passed_alltests )
2793 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2795 INTEGER :: n_Failed_Tests, n_Failed_AllTests
2804 n_failed_tests = n_failed_tests, &
2805 n_failed_alltests = n_failed_alltests )
2807 n_failed_tests = n_failed_tests + 1
2808 n_failed_alltests = n_failed_alltests + 1
2812 test_result = .false., &
2813 n_failed_tests = n_failed_tests, &
2814 n_failed_alltests = n_failed_alltests )
2839 TYPE(UnitTest_type),
INTENT(IN OUT) :: UnitTest
2840 INTEGER :: n_Tests, n_AllTests
2844 n_tests = n_tests, &
2845 n_alltests = n_alltests )
2847 n_tests = n_tests + 1
2848 n_alltests = n_alltests + 1
2852 n_tests = n_tests, &
2853 n_alltests = n_alltests )
2878 TYPE(UnitTest_type),
INTENT(IN) :: UnitTest
2881 CHARACTER(SL) :: Procedure
2882 CHARACTER(SL) :: Message
2883 CHARACTER(SL) :: Fmt
2884 CHARACTER(SL) :: Prefix
2885 CHARACTER(SL) :: Test_Info
2891 Procedure = procedure, &
2901 prefix =
'/,3x,14("-"),/' 2911 prefix =
'/,1x,16("="),/' 2915 prefix =
'/,"INVALID MESSAGE LEVEL!!",/' 2920 WRITE(fmt,
'("(",a,i0,"x,""("",a,"") "",a,"": "",a,1x,a)")') trim(prefix), n_spaces
2921 WRITE( *,fmt=fmt ) trim(
message_level(level)), trim(procedure), trim(test_info), trim(message)
2955 TYPE(UnitTest_Type),
INTENT(IN) :: UnitTest
2956 CHARACTER(*),
INTENT(OUT) :: info
2958 CHARACTER(6) :: PassFail
2965 WRITE( info,
'("Test#",i0,1x,a,".")') n_tests, passfail
3002 REAL(Single),
INTENT(IN) :: x
3004 IF (x > 0.0_single)
THEN 3005 e = 10.0_single**floor(log10(x))
3012 REAL(Double),
INTENT(IN) :: x
3014 IF (x > 0.0_double)
THEN 3015 e = 10.0_double**floor(log10(x))
subroutine, public unittest_setup(UnitTest, Title, Caller, Verbose)
pure subroutine get_property(UnitTest, Verbose, Title, Caller, Level, Procedure, Message, Test_Result, n_Tests, n_Passed_Tests, n_Failed_Tests, n_AllTests, n_Passed_AllTests, n_Failed_AllTests)
pure logical function, public unittest_passed(UnitTest)
elemental real(single) function realsp_get_multiplier(x)
subroutine realdp_isequalwithin_rank1(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine test_passed(UnitTest)
subroutine realdp_isequal_rank1(UnitTest, Expected, Actual)
integer, parameter, public long
subroutine realdp_isequalwithin_scalar(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
integer, parameter setup_level
subroutine test_failed(UnitTest)
subroutine test_info_string(UnitTest, info)
subroutine complexdp_isequal_rank1(UnitTest, Expected, Actual)
subroutine, public unittest_summary(UnitTest)
character(*), parameter green_colour
integer, parameter init_level
character(*), parameter rfmt
character(2), parameter crlf
integer, parameter, public byte
subroutine, public unittest_report(UnitTest)
character(*), dimension(n_message_levels), parameter message_level
subroutine realsp_isequal_scalar(UnitTest, Expected, Actual)
integer, parameter, public double
subroutine realsp_isequalwithin_scalar(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine char_isequal_rank2(UnitTest, Expected, Actual)
subroutine intbyte_isequal_rank2(UnitTest, Expected, Actual)
integer, parameter, public single
integer, parameter, public short
character(*), parameter zfmt
subroutine, public unittest_init(UnitTest, Verbose)
subroutine complexsp_isequal_rank2(UnitTest, Expected, Actual)
pure integer function, public unittest_n_failed(UnitTest)
integer, parameter summary_level
subroutine intshort_isequal_rank2(UnitTest, Expected, Actual)
subroutine complexdp_isequalwithin_rank1(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine complexsp_isequalwithin_scalar(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine intlong_isequal_rank2(UnitTest, Expected, Actual)
subroutine, public unittest_assert(UnitTest, Test)
subroutine complexsp_isequal_rank1(UnitTest, Expected, Actual)
subroutine realdp_isequalwithin_rank2(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine, public unittest_defineversion(Id)
subroutine complexdp_isequalwithin_rank2(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine char_isequal_scalar(UnitTest, Expected, Actual)
subroutine intshort_isequal_rank1(UnitTest, Expected, Actual)
character(*), parameter no_colour
subroutine char_isequal_rank1(UnitTest, Expected, Actual)
integer, parameter report_level
logical, parameter default_verbose
integer, parameter n_message_levels
subroutine test_increment(UnitTest)
subroutine intshort_isequal_scalar(UnitTest, Expected, Actual)
character(*), parameter module_version_id
subroutine intlong_isequal_scalar(UnitTest, Expected, Actual)
subroutine intbyte_isequal_rank1(UnitTest, Expected, Actual)
subroutine complexdp_isequalwithin_scalar(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
elemental real(double) function realdp_get_multiplier(x)
pure subroutine set_property(UnitTest, Verbose, Title, Caller, Level, Procedure, Message, Test_Result, n_Tests, n_Passed_Tests, n_Failed_Tests, n_AllTests, n_Passed_AllTests, n_Failed_AllTests)
subroutine complexdp_isequal_scalar(UnitTest, Expected, Actual)
subroutine intbyte_isequal_scalar(UnitTest, Expected, Actual)
subroutine realsp_isequalwithin_rank1(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
character(*), parameter red_colour
subroutine realsp_isequalwithin_rank2(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine complexsp_isequal_scalar(UnitTest, Expected, Actual)
integer, parameter test_level
pure integer function, public unittest_n_passed(UnitTest)
subroutine complexsp_isequalwithin_rank1(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
subroutine display_message(UnitTest)
subroutine complexsp_isequalwithin_rank2(UnitTest, Expected, Actual, Tolerance, Epsilon_Scale)
pure logical function, public unittest_failed(UnitTest)
subroutine realdp_isequal_rank2(UnitTest, Expected, Actual)
subroutine realdp_isequal_scalar(UnitTest, Expected, Actual)
subroutine intlong_isequal_rank1(UnitTest, Expected, Actual)
subroutine realsp_isequal_rank2(UnitTest, Expected, Actual)
subroutine complexdp_isequal_rank2(UnitTest, Expected, Actual)
subroutine realsp_isequal_rank1(UnitTest, Expected, Actual)
integer, parameter internal_fail_level