From 00ae6b5350d2028782f63228609eb1a4ddbb2cc8 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Sun, 22 Oct 2023 23:17:04 -0500 Subject: [PATCH 1/2] adding more tests --- test/csv_test4.f90 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/csv_test4.f90 diff --git a/test/csv_test4.f90 b/test/csv_test4.f90 new file mode 100644 index 0000000..e73e5d6 --- /dev/null +++ b/test/csv_test4.f90 @@ -0,0 +1,34 @@ +!***************************************************************************************** +!> +! Test of [[csv_utilities]]. + +program csv_test3 + + use csv_utilities + use iso_fortran_env, only: wp => real64 + + implicit none + + integer,dimension(:),allocatable :: ivec + + write(*,*) '' + write(*,*) '============================' + write(*,*) ' csv_test_4 ' + write(*,*) '============================' + write(*,*) '' + + allocate(ivec(10000)) + + ivec = 0 + ivec(500) = 1 + + call sort_ascending(ivec) + if (.not. all(ivec(1:10000-1)==0)) error stop 'sort error' + if (ivec(10000)/=1) error stop 'sort error' + + ivec = unique(ivec,chunk_size=10) + if (.not. all (ivec == [0,1])) error stop 'unique error' + + write(*,*) 'PASSED' + + end program csv_test3 From a0424b6fe6969f3a39db7a02b4d1c1541b7e2951 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Mon, 23 Oct 2023 00:05:44 -0500 Subject: [PATCH 2/2] more tests --- test/csv_test3.f90 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/test/csv_test3.f90 b/test/csv_test3.f90 index 74b598b..623cfae 100644 --- a/test/csv_test3.f90 +++ b/test/csv_test3.f90 @@ -14,6 +14,8 @@ program csv_test3 character(len=30),dimension(:),allocatable :: header, col1 integer :: i character(len=100) :: tmp_str + integer,dimension(:),allocatable :: int_col + logical,dimension(:),allocatable :: log_col write(*,*) '' write(*,*) '============================' @@ -25,27 +27,37 @@ program csv_test3 call f%initialize(verbose = .true.) ! open the file - call f%open('test.csv',n_cols=4,status_ok=status_ok) + call f%open('test.csv',n_cols=6,status_ok=status_ok) ! add header - call f%add(['x','y','z','t']) + call f%add(['x ','y ','z ','t ','int','str']) call f%next_row() ! add some data: call f%add([1.0_wp,2.0_wp,3.0_wp],real_fmt='(F5.3)') call f%add(.true.) + call f%add(1) + call f%add('a') call f%next_row() call f%add([2.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)') call f%add(.false.) + call f%add(1) + call f%add('b') call f%next_row() call f%add([3.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)') call f%add(.false.) + call f%add(1) + call f%add('c') call f%next_row() call f%add([4.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)') call f%add(.false.) + call f%add(1) + call f%add('d') call f%next_row() call f%add([5.0_wp,5.0_wp,6.0_wp],real_fmt='(F5.3)') call f%add(.false.) + call f%add(1) + call f%add('e') call f%next_row() ! finished @@ -70,12 +82,17 @@ program csv_test3 do i = 1, size(col1) print "(*(g0))", ">",trim(col1(i)),"<" end do - do i = 1, 5 write(tmp_str,'(F5.3)') real(i,wp) if (col1(i) /= tmp_str) error stop 'error converting cell to string:'//tmp_str end do + call f%get(4,log_col,status_ok) + if (.not. all(log_col .eqv. [.true.,.false.,.false.,.false.,.false.])) error stop 'error getting logical column' + + call f%get(5,int_col,status_ok) + if (.not. all(int_col==1)) error stop 'error getting integer column' + ! destroy the file call f%destroy()