Skip to content

Commit a0424b6

Browse files
committed
more tests
1 parent 00ae6b5 commit a0424b6

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

test/csv_test3.f90

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ program csv_test3
1414
character(len=30),dimension(:),allocatable :: header, col1
1515
integer :: i
1616
character(len=100) :: tmp_str
17+
integer,dimension(:),allocatable :: int_col
18+
logical,dimension(:),allocatable :: log_col
1719

1820
write(*,*) ''
1921
write(*,*) '============================'
@@ -25,27 +27,37 @@ program csv_test3
2527
call f%initialize(verbose = .true.)
2628

2729
! open the file
28-
call f%open('test.csv',n_cols=4,status_ok=status_ok)
30+
call f%open('test.csv',n_cols=6,status_ok=status_ok)
2931

3032
! add header
31-
call f%add(['x','y','z','t'])
33+
call f%add(['x ','y ','z ','t ','int','str'])
3234
call f%next_row()
3335

3436
! add some data:
3537
call f%add([1.0_wp,2.0_wp,3.0_wp],real_fmt='(F5.3)')
3638
call f%add(.true.)
39+
call f%add(1)
40+
call f%add('a')
3741
call f%next_row()
3842
call f%add([2.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
3943
call f%add(.false.)
44+
call f%add(1)
45+
call f%add('b')
4046
call f%next_row()
4147
call f%add([3.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
4248
call f%add(.false.)
49+
call f%add(1)
50+
call f%add('c')
4351
call f%next_row()
4452
call f%add([4.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
4553
call f%add(.false.)
54+
call f%add(1)
55+
call f%add('d')
4656
call f%next_row()
4757
call f%add([5.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)')
4858
call f%add(.false.)
59+
call f%add(1)
60+
call f%add('e')
4961
call f%next_row()
5062

5163
! finished
@@ -70,12 +82,17 @@ program csv_test3
7082
do i = 1, size(col1)
7183
print "(*(g0))", ">",trim(col1(i)),"<"
7284
end do
73-
7485
do i = 1, 5
7586
write(tmp_str,'(F5.3)') real(i,wp)
7687
if (col1(i) /= tmp_str) error stop 'error converting cell to string:'//tmp_str
7788
end do
7889

90+
call f%get(4,log_col,status_ok)
91+
if (.not. all(log_col .eqv. [.true.,.false.,.false.,.false.,.false.])) error stop 'error getting logical column'
92+
93+
call f%get(5,int_col,status_ok)
94+
if (.not. all(int_col==1)) error stop 'error getting integer column'
95+
7996
! destroy the file
8097
call f%destroy()
8198

0 commit comments

Comments
 (0)