Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: try to fix CMake tests #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 82 additions & 56 deletions files/csv_test.out.ref
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
csv_test_1
============================

read file: ./test.csv
File: test.csv
read file:

File: test.csv

Header Type
id 3
first_name 1
age 2
ok 4
print all the rows:

print all the rows:
1 Julie 80.244 false
2 Jose 11.569 true
3 Lois 12.339 true
Expand All @@ -33,59 +33,85 @@ ok 4
17 Carol 54.498 false
18 Alice 2.505 true
19 Randy 39.775 false

get some vectors:

age:
80.244
11.569
12.339
63.173
57.063
79.705
19.347
16.909
67.749
43.705
9.931
72.657
10.901
9.966
10.875
33.268
54.498
2.505
39.775
read file: ./test_2_columns.csv

File: test_2_columns.csv


get some vectors:

get real(wp) vector:
age:
80.244
11.569
12.339
63.173
57.063
79.705
19.347
16.909
67.749
43.705
9.931
72.657
10.901
9.966
10.875
33.268
54.498
2.505
39.775
get real(sp) vector:
age:
80.244
11.569
12.339
63.173
57.063
79.705
19.347
16.909
67.749
43.705
9.931
72.657
10.901
9.966
10.875
33.268
54.498
2.505
39.775
read file:

File: test_2_columns.csv

Header Type
id 3
first_name 1
print all the rows:

print all the rows:
2 Jose
3 Lois
4 Walter

get some vectors:

name:
Jose
Lois
Walter

============================
csv_write_test
============================


============================
csv_read_test
============================

x= 1.0000000000000000 4.0000000000000000
y= 2.0000000000000000 5.0000000000000000
z= 3.0000000000000000 6.0000000000000000
t= T F

get some vectors:

name:
Jose
Lois
Walter

============================
csv_write_test
============================


============================
csv_read_test
============================

x= 1.000 4.000 1.500 4.500
y= 2.000 5.000 2.500 5.500
z= 3.000 6.000 3.500 6.500
t= T F T F
x= 1.000 4.000 1.500 4.500
y= 2.000 5.000 2.500 5.500
z= 3.000 6.000 3.500 6.500
t= T F T F
2 changes: 2 additions & 0 deletions files/test2.csv.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"x","y","z","t"
0.10000000000000000E+0001,0.20000000000000000E+0001,0.30000000000000000E+0001,T
4.000,5.000,6.000,F
0.15000000000000000E+0001,0.25000000000000000E+0001,0.35000000000000000E+0001,T
4.500,5.500,6.500,F
2 changes: 2 additions & 0 deletions files/test_write.csv.ref
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"x","y","z","t"
1.000,2.000,3.000,T
4.000,5.000,6.000,F
1.500,2.500,3.500,T
4.500,5.500,6.500,F
72 changes: 36 additions & 36 deletions src/tests/csv_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ subroutine csv_test_1()
file = trim(dirs_to_try(k))//trim(files_to_test(ifile))
if (file_exists(file)) exit ! found it
end do
write(*,*) 'read file: '//trim(file)
write(*,*) 'read file: '

! read the file:
if (ifile==1) then
Expand All @@ -70,45 +70,45 @@ subroutine csv_test_1()
error stop 'could not open file'
end if

write(*,*) ''
write(*,*) 'File: '//trim(files_to_test(ifile))
write(*,'(A)') ''
write(*,'(A)') 'File: '//trim(files_to_test(ifile))
! print the header and type info:
call f%get_header(header,status_ok)
call f%variable_types(itypes,status_ok)
write(*,*) ''
write(*,'(A)') ''
write(*,'(*(A30,1X,A4))') 'Header', 'Type'
do i=1,size(header)
write(*,'(*(A30,1X,I4))') header(i), itypes(i)
end do

write(*,*) ''
write(*,*) 'print all the rows:'
write(*,'(A)') ''
write(*,'(A)') 'print all the rows:'

call f%get(csv_data,status_ok)
do i=1,size(csv_data,1)
write(*,'(*(A30,1X))') csv_data(i,:)
end do

write(*,*) ''
write(*,*) 'get some vectors:'
write(*,'(A)') ''
write(*,'(A)') 'get some vectors:'
if (ifile==1) then
write(*,*) ''
write(*,*) 'get real(wp) vector:'
write(*,*) 'age:'
write(*,'(A)') ''
write(*,'(A)') 'get real(wp) vector:'
write(*,'(A)') 'age:'
call f%get(3,x,status_ok)
write(*,'(F6.3,1x)',advance='NO') x
write(*,*) ''
write(*,*) 'get real(sp) vector:'
write(*,*) 'age:'
write(*,'(A)') ''
write(*,'(A)') 'get real(sp) vector:'
write(*,'(A)') 'age:'
call f%get(3,y,status_ok)
write(*,'(F6.3,1x)',advance='NO') y
write(*,*) ''
write(*,'(A)') ''
else
write(*,*) ''
write(*,*) 'name:'
write(*,'(A)') ''
write(*,'(A)') 'name:'
call f%get(2,names,status_ok)
write(*,'(A10,1x)',advance='NO') names
write(*,*) ''
write(*,'(A)') ''
end if

end do
Expand Down Expand Up @@ -146,11 +146,11 @@ subroutine csv_write_test()
type(csv_file) :: f
logical :: status_ok

write(*,*) ''
write(*,*) '============================'
write(*,*) ' csv_write_test '
write(*,*) '============================'
write(*,*) ''
write(*,'(A)') ''
write(*,'(A)') '============================'
write(*,'(A)') ' csv_write_test '
write(*,'(A)') '============================'
write(*,'(A)') ''

! open the file
call f%open('test_write.csv',n_cols=4,status_ok=status_ok)
Expand Down Expand Up @@ -195,11 +195,11 @@ subroutine csv_read_test()
logical :: status_ok
integer,dimension(:),allocatable :: itypes

write(*,*) ''
write(*,*) '============================'
write(*,*) ' csv_read_test '
write(*,*) '============================'
write(*,*) ''
write(*,'(A)') ''
write(*,'(A)') '============================'
write(*,'(A)') ' csv_read_test '
write(*,'(A)') '============================'
write(*,'(A)') ''

! read the file
call f%read('test_write.csv',header_row=1,status_ok=status_ok)
Expand All @@ -216,20 +216,20 @@ subroutine csv_read_test()
call f%get(3,z,status_ok)
call f%get(4,t,status_ok)

write(*,*) 'x=',x
write(*,*) 'y=',y
write(*,*) 'z=',z
write(*,*) 't=',t
write(*,'(A,1X,*(F12.3,1X))') 'x=',x
write(*,'(A,1X,*(F12.3,1X))') 'y=',y
write(*,'(A,1X,*(F12.3,1X))') 'z=',z
write(*,'(A,1X,*(L1,1X))') 't=',t

call f%get(1,u,status_ok)
call f%get(2,v,status_ok)
call f%get(3,w,status_ok)
call f%get(4,t,status_ok)

write(*,*) 'x=',u
write(*,*) 'y=',v
write(*,*) 'z=',w
write(*,*) 't=',t
write(*,'(A,1X,*(F12.3,1X))') 'x=',u
write(*,'(A,1X,*(F12.3,1X))') 'y=',v
write(*,'(A,1X,*(F12.3,1X))') 'z=',w
write(*,'(A,1X,*(L1,1X))') 't=',t

! destroy the file
call f%destroy()
Expand Down