@@ -62,12 +62,12 @@ subroutine test_10(error_cnt)
6262
6363 integer ,intent (out ) :: error_cnt
6464
65+ character (len= 256 ),dimension (:),allocatable :: str_vec
6566 type (json_file) :: f,f2
6667 type (json_value),pointer :: p
6768 character (len= :),allocatable :: str
6869 logical :: found,lval
6970 integer :: var_type,n_children
70- character (len= 256 ),dimension (:),allocatable :: str_vec
7171
7272 character (len=* ),parameter :: json_str = ' { "blah": 123 }'
7373
@@ -236,8 +236,105 @@ subroutine test_10(error_cnt)
236236 write (error_unit,' (A)' ) ' ...success'
237237 end if
238238
239- ! ....
239+ !- -------------------------------
240+
241+ write (error_unit,' (A)' ) ' '
242+ write (error_unit,' (A)' ) ' json_file_get_integer...'
243+ call f2% get(' $' ,p,found) ! get root
244+ if (json_failed()) then
245+ call json_print_error_message(error_unit)
246+ error_cnt = error_cnt + 1
247+ else
248+ if (found) then
249+ write (error_unit,' (A)' ) ' ...success'
250+ write (error_unit,' (A)' ) ' json_remove_if_present...'
251+ call json_remove_if_present(p,' version.patch' )
252+ if (json_failed()) then
253+ call json_print_error_message(error_unit)
254+ error_cnt = error_cnt + 1
255+ else
256+ write (error_unit,' (A)' ) ' ...success'
257+ end if
258+ else
259+ write (error_unit,' (A)' ) ' Error: variable was not there.'
260+ error_cnt = error_cnt + 1
261+ end if
262+ end if
263+
264+ write (error_unit,' (A)' ) ' json_update_logical...'
265+ call json_update(p,' data(1).tf1' ,.true. ,found)
266+ if (json_failed()) then
267+ call json_print_error_message(error_unit)
268+ error_cnt = error_cnt + 1
269+ else
270+ if (found) then
271+ write (error_unit,' (A)' ) ' ...success'
272+ else
273+ write (error_unit,' (A)' ) ' Error: variable was not there.'
274+ error_cnt = error_cnt + 1
275+ end if
276+ end if
277+
278+ write (error_unit,' (A)' ) ' json_update_double...'
279+ call json_update(p,' data(2).real' ,- 1.0d0 ,found)
280+ if (json_failed()) then
281+ call json_print_error_message(error_unit)
282+ error_cnt = error_cnt + 1
283+ else
284+ if (found) then
285+ write (error_unit,' (A)' ) ' ...success'
286+ else
287+ write (error_unit,' (A)' ) ' Error: variable was not there.'
288+ error_cnt = error_cnt + 1
289+ end if
290+ end if
291+
292+ write (error_unit,' (A)' ) ' json_get_logical...'
293+ call json_get(p,' data(1).tf1' ,lval,found)
294+ if (json_failed()) then
295+ call json_print_error_message(error_unit)
296+ error_cnt = error_cnt + 1
297+ else
298+ if (found) then
299+ write (error_unit,' (A)' ) ' ...success'
300+ else
301+ write (error_unit,' (A)' ) ' Error: variable was not there.'
302+ error_cnt = error_cnt + 1
303+ end if
304+ end if
305+
306+ write (error_unit,' (A)' ) ' json_get_string_vec...'
307+ call json_get(p,' files' ,str_vec,found)
308+ if (json_failed()) then
309+ call json_print_error_message(error_unit)
310+ error_cnt = error_cnt + 1
311+ else
312+ ! also make sure the values are correct:
313+ if (found .and. size (str_vec)==5 .and. &
314+ str_vec(1 )==' ..\path\to\files\file1.txt' ) then
315+ write (error_unit,' (A)' ) ' ...success'
316+ else
317+ write (error_unit,' (A)' ) ' Error: incorrect result: ' // trim (str_vec(1 ))
318+ error_cnt = error_cnt + 1
319+ end if
320+ end if
321+
322+ write (error_unit,' (A)' ) ' json_create...'
323+ write (error_unit,' (A)' ) ' json_create_logical...' ; call json_destroy(p); call json_create_logical(p,.true. ,' foo' )
324+ write (error_unit,' (A)' ) ' json_create_integer...' ; call json_destroy(p); call json_create_integer(p,1000 ,' foo' )
325+ write (error_unit,' (A)' ) ' json_create_double ...' ; call json_destroy(p); call json_create_double (p,9.0d0 ,' foo' )
326+ write (error_unit,' (A)' ) ' json_create_string ...' ; call json_destroy(p); call json_create_string (p,' foo' ,' bar' )
327+ write (error_unit,' (A)' ) ' json_create_null ...' ; call json_destroy(p); call json_create_null (p,' foo' )
328+ write (error_unit,' (A)' ) ' json_create_object ...' ; call json_destroy(p); call json_create_object (p,' foo' )
329+ if (json_failed()) then
330+ call json_print_error_message(error_unit)
331+ error_cnt = error_cnt + 1
332+ else
333+ write (error_unit,' (A)' ) ' ...success'
334+ end if
335+
240336
337+ !- -------------------------------
241338
242339 ! cleanup:
243340 call f% destroy()
0 commit comments