Skip to content

Commit 57d517f

Browse files
committed
Refactor the test
1 parent 5e9565e commit 57d517f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/tests/loadtxt/test_savetxt.f90

+18-12
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ program test_loadtxt
44
use stdlib_experimental_error, only: assert
55
implicit none
66

7-
real(dp) :: d(3, 2), e(2, 3)
8-
real(dp), allocatable :: d2(:, :)
9-
d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
10-
call savetxt("tmp.dat", d)
11-
call loadtxt("tmp.dat", d2)
12-
call assert(all(shape(d2) == [3, 2]))
13-
call assert(all(abs(d-d2) < epsilon(1._dp)))
7+
call test1()
148

15-
e = reshape([1, 2, 3, 4, 5, 6], [2, 3])
16-
call savetxt("tmp.dat", e)
17-
call loadtxt("tmp.dat", d2)
18-
call assert(all(shape(d2) == [2, 3]))
19-
call assert(all(abs(e-d2) < epsilon(1._dp)))
9+
contains
10+
11+
subroutine test1()
12+
real(dp) :: d(3, 2), e(2, 3)
13+
real(dp), allocatable :: d2(:, :)
14+
d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
15+
call savetxt("tmp.dat", d)
16+
call loadtxt("tmp.dat", d2)
17+
call assert(all(shape(d2) == [3, 2]))
18+
call assert(all(abs(d-d2) < epsilon(1._dp)))
19+
20+
e = reshape([1, 2, 3, 4, 5, 6], [2, 3])
21+
call savetxt("tmp.dat", e)
22+
call loadtxt("tmp.dat", d2)
23+
call assert(all(shape(d2) == [2, 3]))
24+
call assert(all(abs(e-d2) < epsilon(1._dp)))
25+
end subroutine
2026

2127
end program

0 commit comments

Comments
 (0)