Test the rename
function.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | error_cnt | report number of errors to caller |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
subroutine test_17(error_cnt)
!! Test the `rename` function.
implicit none
integer,intent(out) :: error_cnt !! report number of errors to caller
type(json_core) :: json
type(json_value),pointer :: p,q
write(error_unit,'(A)') ''
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ' TEST 17'
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ''
error_cnt = 0
write(error_unit,'(A)') ''
write(error_unit,'(A)') 'Original:'
call json%parse(p, '{"city": ["New York","Los Angeles","Chicago"], '//&
'"value": 1, "iflag": true, "struct":{"vec":[1,2,3]}}')
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
call json%print(p,error_unit)
write(error_unit,'(A)') ''
write(error_unit,'(A)') 'Rename: "city" to "cities"'
call json%get(p,'city',q)
call json%rename(q,'cities')
call json%print(p,output_unit)
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
nullify(q)
!verify that it was renamed:
call json%get(p,'cities',q)
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
else
write(error_unit,'(A)') 'Success!'
end if
nullify(q)
!cleanup:
call json%destroy(p)
end subroutine test_17