finer_test_parse Program

Uses

  • program~~finer_test_parse~~UsesGraph program~finer_test_parse finer_test_parse module~finer finer program~finer_test_parse->module~finer penf penf program~finer_test_parse->penf module~finer_backend finer_backend module~finer->module~finer_backend module~finer_file_ini_t finer_file_ini_t module~finer->module~finer_file_ini_t module~finer_backend->penf module~finer_file_ini_t->penf module~finer_file_ini_t->module~finer_backend iso_fortran_env iso_fortran_env module~finer_file_ini_t->iso_fortran_env module~finer_section_t finer_section_t module~finer_file_ini_t->module~finer_section_t module~finer_option_t finer_option_t module~finer_file_ini_t->module~finer_option_t stringifor stringifor module~finer_file_ini_t->stringifor module~finer_section_t->penf module~finer_section_t->module~finer_backend module~finer_section_t->module~finer_option_t module~finer_section_t->stringifor module~finer_option_t->penf module~finer_option_t->module~finer_backend module~finer_option_t->stringifor

FiNeR test: basic parse.

Usage

 ./finer_test_parse

Calls

program~~finer_test_parse~~CallsGraph program~finer_test_parse finer_test_parse str str program~finer_test_parse->str

Contents

Source Code


Variables

TypeAttributesNameInitial
real(kind=R4P), allocatable:: array(:)

Array option.

integer(kind=I4P) :: error

Error code.

type(file_ini) :: fini

INI file handler.

character(len=:), allocatable:: source

Testing string.

character(len=:), allocatable:: string

String option.

logical :: test_passed(2)

List of passed tests.


Source Code

program finer_test_parse
!< FiNeR test: basic parse.
!<
!<### Usage
!<```bash
!< ./finer_test_parse
!<```
use finer, only :  file_ini
use penf, only : I4P, R4P, str

implicit none
type(file_ini)                :: fini           !< INI file handler.
character(len=:), allocatable :: source         !< Testing string.
character(len=:), allocatable :: string         !< String option.
real(R4P), allocatable        :: array(:)       !< Array option.
integer(I4P)                  :: error          !< Error code.
logical                       :: test_passed(2) !< List of passed tests.

source = '[section-1]'//new_line('a')//                                &
         '; option-1 = two ; commented line'//new_line('a')//          &
         '# option-1 = three ; commented line'//new_line('a')//        &
         'option-1 = one ; this is an inline comment'//new_line('a')// &
         '! option-1 = four ; commented line'//new_line('a')//         &
         'option-2 = 2.'//new_line('a')//                              &
         '           3. ; continued line'//new_line('a')//             &
         'option-3 = bar'//new_line('a')//                             &
         '[section-2]'//new_line('a')//                                &
         'option-1 = foo'//new_line('a')//                             &
         '[section-3]'//new_line('a')//                                &
         'option-1 = foo'//new_line('a')//                             &
         'option-2 = bar'//new_line('a')

print "(A)", 'Source input'//new_line('a')//new_line('a')//source//new_line('a')//new_line('a')//'Parse results'//new_line('a')

call fini%load(source=source)

string = repeat(' ', 999)
call fini%get(section_name='section-1', option_name='option-1', val=string, error=error)
test_passed(1) = ((error==0).and.(trim(string)=='one'))
print "(A,L1)", '[section-1].(option-1) = "'//trim(string)//'", is correct? ', test_passed(1)

allocate(array(1:fini%count_values(section_name='section-1', option_name='option-2')))
call fini%get(section_name='section-1', option_name='option-2', val=array, error=error)
test_passed(2) = ((error==0).and.(array(1)==2._R4P).and.(array(2)==3._R4P))
print "(A,L1)", '[section-1].(option-2) = "'//trim(str(array))//'", is correct? ', test_passed(2)

print "(A,L1)", new_line('a')//'Are all tests passed? ', all(test_passed)
endprogram finer_test_parse