Open
Description
At present, test-drive
can check scalars of Fortran built-in types, such as logical
scalars, integer
scalars, and real
scalars; however, it does not support arrays, so users need to write loops to check the contents of arrays:
do i = 1, size(array)
call check(error, array(i), expected(i), ...)
if (allocated(error)) return
end do
It would be a good feature to support array checking. Since the check
subroutine usually only needs to read the array without changing the contents of the array, I think using reshape
to convert it into a rank-1 array for checking would be an acceptable solution.
subroutine check_array(error, actual, expected, ...)
type(error_type), allocatable, intent(out) :: error
class(*), intent(in) :: actual(:)
class(*), intent(in) :: expected(:)
...
end subroutine
! The `array` can be of any shape, and is finally determined to be a rank-1 array by `reshape`
call check(error, reshape(array, shape=[size(array)], expected, ...)
if (allocated(error)) return