Skip to content

Commit 1974cb4

Browse files
committed
Test iomsg deallocated in save_npy
1 parent 5d7e177 commit 1974cb4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/tests/io/test_npy.f90

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ subroutine collect_npy(testsuite)
3434
new_unittest("duplicate-descr", test_duplicate_descr, should_fail=.true.), &
3535
new_unittest("missing-descr", test_missing_descr, should_fail=.true.), &
3636
new_unittest("missing-fortran_order", test_missing_fortran_order, should_fail=.true.), &
37-
new_unittest("missing-shape", test_missing_shape, should_fail=.true.) &
37+
new_unittest("missing-shape", test_missing_shape, should_fail=.true.), &
38+
new_unittest("iomsg-deallocated", test_iomsg_deallocated) &
3839
]
3940
end subroutine collect_npy
4041

@@ -619,6 +620,27 @@ subroutine test_missing_shape(error)
619620
call check(error, stat, msg)
620621
end subroutine test_missing_shape
621622

623+
subroutine test_iomsg_deallocated(error)
624+
!> Error handling
625+
type(error_type), allocatable, intent(out) :: error
626+
627+
integer :: stat
628+
character(len=:), allocatable :: msg
629+
630+
character(len=*), parameter :: filename = ".test-iomsg-deallocated.npy"
631+
real(sp), allocatable :: input(:, :), output(:, :)
632+
633+
msg = "This message should be deallocated."
634+
635+
allocate(input(12, 5))
636+
call random_number(input)
637+
call save_npy(filename, input, stat, msg)
638+
call delete_file(filename)
639+
640+
call check(error,.not. allocated(msg), "Message wrongly allocated.")
641+
642+
end subroutine
643+
622644
subroutine delete_file(filename)
623645
character(len=*), intent(in) :: filename
624646

0 commit comments

Comments
 (0)