finer_test_update_option Program

Uses

  • program~~finer_test_update_option~~UsesGraph program~finer_test_update_option finer_test_update_option module~finer finer program~finer_test_update_option->module~finer iso_fortran_env iso_fortran_env program~finer_test_update_option->iso_fortran_env penf penf program~finer_test_update_option->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->iso_fortran_env module~finer_file_ini_t->penf module~finer_file_ini_t->module~finer_backend 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: update existing option.

Usage

 ./finer_test_update_option

Contents


Variables

TypeAttributesNameInitial
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(3)

List of passed tests.


Source Code

program finer_test_update_option
!< FiNeR test: update existing option.
!<
!<### Usage
!<```bash
!< ./finer_test_update_option
!<```
use, intrinsic :: iso_fortran_env, only : stdout=>output_unit
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.
integer(I4P)                  :: error          !< Error code.
logical                       :: test_passed(3) !< List of passed tests.

call fini%load(filename='./src/tests/update_option.ini')
call fini%print(unit=stdout)

string = repeat(' ', 999)
call fini%get(section_name='sec-foo', option_name='bar2', val=string, error=error)
test_passed(1) = ((error==0).and.(trim(string)=='1.102325'))

call fini%add(section_name='sec-foo', option_name='bar2',val='0.99')
call fini%print(unit=stdout)

call fini%get(section_name='sec-foo', option_name='bar2', val=string, error=error)
test_passed(2) = ((error==0).and.(trim(string)=='0.99'))

call fini%get(section_name='sec-foo', option_name='bar', val=string, error=error)
test_passed(3) = ((error==0).and.(trim(string)=='-0.583000E+02'))

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