Skip to content

Commit 924ee54

Browse files
authored
Merge pull request #65 from certik/quad
Split the loadtxt qp tests and skip them on Win
2 parents 1903066 + 8497560 commit 924ee54

File tree

6 files changed

+94
-32
lines changed

6 files changed

+94
-32
lines changed

.github/workflows/ci_windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
if: failure()
2929

3030
- name: CTest
31-
run: ctest --output-on-failure --parallel -V
31+
run: ctest --output-on-failure --parallel -V -LE quadruple_precision
3232
working-directory: build
3333

3434
- uses: actions/upload-artifact@v1

src/tests/loadtxt/CMakeLists.txt

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@ target_link_libraries(test_loadtxt fortran_stdlib)
44
add_executable(test_savetxt test_savetxt.f90)
55
target_link_libraries(test_savetxt fortran_stdlib)
66

7-
add_test(NAME load_text COMMAND $<TARGET_FILE:test_loadtxt> ${CMAKE_CURRENT_BINARY_DIR}
7+
add_executable(test_loadtxt_qp test_loadtxt_qp.f90)
8+
target_link_libraries(test_loadtxt_qp fortran_stdlib)
9+
10+
add_executable(test_savetxt_qp test_savetxt_qp.f90)
11+
target_link_libraries(test_savetxt_qp fortran_stdlib)
12+
13+
add_test(NAME loadtxt COMMAND $<TARGET_FILE:test_loadtxt> ${CMAKE_CURRENT_BINARY_DIR}
14+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
15+
add_test(NAME savetxt COMMAND $<TARGET_FILE:test_savetxt> ${CMAKE_CURRENT_BINARY_DIR}
816
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
9-
add_test(NAME save_text COMMAND $<TARGET_FILE:test_savetxt> ${CMAKE_CURRENT_BINARY_DIR}
17+
add_test(NAME loadtxt_qp COMMAND $<TARGET_FILE:test_loadtxt_qp> ${CMAKE_CURRENT_BINARY_DIR}
1018
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
19+
add_test(NAME savetxt_qp COMMAND $<TARGET_FILE:test_savetxt_qp> ${CMAKE_CURRENT_BINARY_DIR}
20+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
21+
22+
set_tests_properties(loadtxt_qp PROPERTIES LABELS quadruple_precision)
23+
set_tests_properties(savetxt_qp PROPERTIES LABELS quadruple_precision)

src/tests/loadtxt/test_loadtxt.f90

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
program test_loadtxt
2-
use iso_fortran_env, only: sp=>real32, dp=>real64 ,qp=>real128
2+
use iso_fortran_env, only: sp=>real32, dp=>real64
33
use stdlib_experimental_io, only: loadtxt
44
implicit none
55

66
real(sp), allocatable :: s(:, :)
77
real(dp), allocatable :: d(:, :)
8-
!real(qp), allocatable :: q(:, :)
98

109
call loadtxt("array1.dat", s)
1110
call print_array(s)
@@ -22,9 +21,6 @@ program test_loadtxt
2221
call loadtxt("array4.dat", d)
2322
call print_array(d)
2423

25-
!call loadtxt("array4.dat", q)
26-
!call print_array(q)
27-
2824
contains
2925

3026
subroutine print_array(a)
@@ -41,10 +37,6 @@ subroutine print_array(a)
4137
do i = 1, size(a, 1)
4238
print *, a(i, :)
4339
end do
44-
type is(real(qp))
45-
do i = 1, size(a, 1)
46-
print *, a(i, :)
47-
end do
4840
class default
4941
write(*,'(a)')'The proposed type is not supported'
5042
error stop

src/tests/loadtxt/test_loadtxt_qp.f90

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
program test_loadtxt_qp
2+
use iso_fortran_env, only: qp=>real128
3+
use stdlib_experimental_io, only: loadtxt
4+
implicit none
5+
6+
real(qp), allocatable :: q(:, :)
7+
8+
call loadtxt("array4.dat", q)
9+
call print_array(q)
10+
11+
contains
12+
13+
subroutine print_array(a)
14+
class(*),intent(in) :: a(:, :)
15+
integer :: i
16+
print *, "Array, shape=(", size(a, 1), ",", size(a, 2), ")"
17+
18+
select type(a)
19+
type is(real(qp))
20+
do i = 1, size(a, 1)
21+
print *, a(i, :)
22+
end do
23+
class default
24+
write(*,'(a)')'The proposed type is not supported'
25+
error stop
26+
end select
27+
28+
end subroutine
29+
30+
end program

src/tests/loadtxt/test_savetxt.f90

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
program test_loadtxt
2-
use iso_fortran_env, only: sp=>real32, dp=>real64 ,qp=>real128
1+
program test_savetxt
2+
use iso_fortran_env, only: sp=>real32, dp=>real64
33
use stdlib_experimental_io, only: loadtxt, savetxt
44
use stdlib_experimental_error, only: assert
55
implicit none
@@ -10,7 +10,6 @@ program test_loadtxt
1010

1111
call test_sp(outpath)
1212
call test_dp(outpath)
13-
!call test_qp(outpath)
1413

1514
contains
1615

@@ -62,21 +61,4 @@ subroutine test_dp(outpath)
6261
call assert(all(abs(e-d2) < epsilon(1._dp)))
6362
end subroutine
6463

65-
subroutine test_qp(outpath)
66-
character(*), intent(in) :: outpath
67-
real(qp) :: d(3, 2), e(2, 3)
68-
real(qp), allocatable :: d2(:, :)
69-
d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
70-
call savetxt(outpath, d)
71-
call loadtxt(outpath, d2)
72-
call assert(all(shape(d2) == [3, 2]))
73-
call assert(all(abs(d-d2) < epsilon(1._qp)))
74-
75-
e = reshape([1, 2, 3, 4, 5, 6], [2, 3])
76-
call savetxt(outpath, e)
77-
call loadtxt(outpath, d2)
78-
call assert(all(shape(d2) == [2, 3]))
79-
call assert(all(abs(e-d2) < epsilon(1._qp)))
80-
end subroutine
81-
8264
end program

src/tests/loadtxt/test_savetxt_qp.f90

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
program test_savetxt_qp
2+
use iso_fortran_env, only: qp=>real128
3+
use stdlib_experimental_io, only: loadtxt, savetxt
4+
use stdlib_experimental_error, only: assert
5+
implicit none
6+
7+
character(:), allocatable :: outpath
8+
9+
outpath = get_outpath() // "/tmp_qp.dat"
10+
11+
call test_qp(outpath)
12+
13+
contains
14+
15+
function get_outpath() result(outpath)
16+
integer :: ierr
17+
character(256) :: argv
18+
character(:), allocatable :: outpath
19+
20+
call get_command_argument(1, argv, status=ierr)
21+
if (ierr==0) then
22+
outpath = trim(argv)
23+
else
24+
outpath = '.'
25+
endif
26+
end function get_outpath
27+
28+
subroutine test_qp(outpath)
29+
character(*), intent(in) :: outpath
30+
real(qp) :: d(3, 2), e(2, 3)
31+
real(qp), allocatable :: d2(:, :)
32+
d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
33+
call savetxt(outpath, d)
34+
call loadtxt(outpath, d2)
35+
call assert(all(shape(d2) == [3, 2]))
36+
call assert(all(abs(d-d2) < epsilon(1._qp)))
37+
38+
e = reshape([1, 2, 3, 4, 5, 6], [2, 3])
39+
call savetxt(outpath, e)
40+
call loadtxt(outpath, d2)
41+
call assert(all(shape(d2) == [2, 3]))
42+
call assert(all(abs(e-d2) < epsilon(1._qp)))
43+
end subroutine
44+
45+
end program

0 commit comments

Comments
 (0)