From efeed13d8fe958dad376a3d292986ec1601d53ed Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 31 Jul 2023 11:04:58 +0200 Subject: [PATCH] include more unit tests for Fortran --- src/IO.f90 | 7 ++++--- src/misc.f90 | 1 + src/rotations.f90 | 9 +++++---- src/test/DAMASK_test.f90 | 24 ++++++++++++++++++++++-- src/test/test_IO.f90 | 17 +++++++++++++++++ src/test/test_misc.f90 | 17 +++++++++++++++++ src/test/test_rotations.f90 | 17 +++++++++++++++++ 7 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 src/test/test_IO.f90 create mode 100644 src/test/test_misc.f90 create mode 100644 src/test/test_rotations.f90 diff --git a/src/IO.f90 b/src/IO.f90 index 9e0b4c40d..6f34d1b7f 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -26,6 +26,7 @@ module IO public :: & IO_init, & + IO_selfTest, & IO_read, & IO_readlines, & IO_isBlank, & @@ -55,7 +56,7 @@ subroutine IO_init() print'(/,1x,a)', '<<<+- IO init -+>>>'; flush(IO_STDOUT) - call selfTest() + call IO_selfTest() end subroutine IO_init @@ -763,7 +764,7 @@ end subroutine panel !-------------------------------------------------------------------------------------------------- !> @brief Check correctness of some IO functions. !-------------------------------------------------------------------------------------------------- -subroutine selfTest() +subroutine IO_selfTest() integer, dimension(:), allocatable :: chunkPos character(len=:), allocatable :: str,out @@ -846,6 +847,6 @@ subroutine selfTest() if ('abc,'//IO_EOL//'xxdefg,'//IO_EOL//'xxhij' /= IO_wrapLines('abc,defg, hij',filler='xx',length=4)) & error stop 'IO_wrapLines/7' -end subroutine selfTest +end subroutine IO_selfTest end module IO diff --git a/src/misc.f90 b/src/misc.f90 index 47c23757f..902a5b731 100644 --- a/src/misc.f90 +++ b/src/misc.f90 @@ -19,6 +19,7 @@ module misc public :: & misc_init, & + misc_selfTest, & misc_optional, & misc_prefixOptions diff --git a/src/rotations.f90 b/src/rotations.f90 index 58aa87ee0..fa0da2b0a 100644 --- a/src/rotations.f90 +++ b/src/rotations.f90 @@ -92,6 +92,7 @@ module rotations public :: & rotations_init, & + rotations_selfTest, & eu2om contains @@ -99,14 +100,14 @@ contains !-------------------------------------------------------------------------------------------------- !> @brief Do self test. !-------------------------------------------------------------------------------------------------- -subroutine rotations_init +subroutine rotations_init() print'(/,1x,a)', '<<<+- rotations init -+>>>'; flush(IO_STDOUT) print'(/,1x,a)', 'D. Rowenhorst et al., Modelling and Simulation in Materials Science and Engineering 23:083501, 2015' print'( 1x,a)', 'https://doi.org/10.1088/0965-0393/23/8/083501' - call selfTest() + call rotations_selfTest() end subroutine rotations_init @@ -757,7 +758,7 @@ end function conjugateQuaternion !-------------------------------------------------------------------------------------------------- !> @brief Check correctness of some rotations functions. !-------------------------------------------------------------------------------------------------- -subroutine selfTest() +subroutine rotations_selfTest() type(tRotation) :: R real(pREAL), dimension(4) :: qu @@ -841,7 +842,7 @@ subroutine selfTest() end function quaternion_equal -end subroutine selfTest +end subroutine rotations_selfTest end module rotations diff --git a/src/test/DAMASK_test.f90 b/src/test/DAMASK_test.f90 index 8460a9fab..0904b71a0 100644 --- a/src/test/DAMASK_test.f90 +++ b/src/test/DAMASK_test.f90 @@ -4,10 +4,17 @@ program DAMASK_test use HDF5_utilities use test_prec - use test_tables use test_crystal + use test_IO + use test_rotations + use test_misc + use test_tables use test_HDF5_utilities + external :: quit + + call parallelization_init() + print('(/,a)'), 'begin test prec' call test_prec_run() print('(a)'), 'begin test prec' @@ -20,11 +27,24 @@ program DAMASK_test call test_crystal_run() print('(a)'), 'end test crystal' - call parallelization_init() + print('(/,a)'), 'begin test rotations' + call test_rotations_run() + print('(a)'), 'end test rotations' + + print('(/,a)'), 'begin test IO' + call test_IO_run() + print('(a)'), 'end test IO' + + print('(/,a)'), 'begin test misc' + call test_misc_run() + print('(a)'), 'end test misc' + call HDF5_utilities_init() print('(/,a)'), 'begin test HDF5_utilities' call test_HDF5_utilities_run() print('(a)'), 'begin test HDF5_utilities' + call quit(0) + end program DAMASK_test diff --git a/src/test/test_IO.f90 b/src/test/test_IO.f90 new file mode 100644 index 000000000..cae7f76c4 --- /dev/null +++ b/src/test/test_IO.f90 @@ -0,0 +1,17 @@ +module test_IO + use IO + + implicit none(type,external) + + private + public :: test_IO_run + + contains + +subroutine test_IO_run() + + call IO_selfTest() + +end subroutine test_IO_run + +end module test_IO diff --git a/src/test/test_misc.f90 b/src/test/test_misc.f90 new file mode 100644 index 000000000..3fcdf19b1 --- /dev/null +++ b/src/test/test_misc.f90 @@ -0,0 +1,17 @@ +module test_misc + use misc + + implicit none(type,external) + + private + public :: test_misc_run + + contains + +subroutine test_misc_run() + + call misc_selfTest() + +end subroutine test_misc_run + +end module test_misc diff --git a/src/test/test_rotations.f90 b/src/test/test_rotations.f90 new file mode 100644 index 000000000..9cf9b7ffd --- /dev/null +++ b/src/test/test_rotations.f90 @@ -0,0 +1,17 @@ +module test_rotations + use rotations + + implicit none(type,external) + + private + public :: test_rotations_run + + contains + +subroutine test_rotations_run() + + call rotations_selfTest() + +end subroutine test_rotations_run + +end module test_rotations