@@ -63,9 +63,12 @@ subroutine test_7(error_cnt)
6363
6464 integer ,intent (out ) :: error_cnt
6565
66- type (json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string
66+ type (json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string,p
6767 logical :: found
68+ character (kind= CK,len= 1 ), dimension (:), allocatable :: strvec
69+ character (kind= CK,len= :), allocatable :: string
6870
71+ found= .false.
6972 error_cnt = 0
7073 call json_initialize()
7174 if (json_failed()) then
@@ -141,6 +144,12 @@ subroutine test_7(error_cnt)
141144 call json_print_error_message(error_unit)
142145 error_cnt = error_cnt + 1
143146 end if
147+ call json_get_child(a,' chars' ,p)
148+ call json_get(p,strvec)
149+ if (json_failed()) then
150+ call json_print_error_message(error_unit)
151+ error_cnt = error_cnt + 1
152+ end if
144153 call json_create_object(c,' c' )
145154 if (json_failed()) then
146155 call json_print_error_message(error_unit)
@@ -202,23 +211,6 @@ subroutine test_7(error_cnt)
202211 call json_print_error_message(error_unit)
203212 error_cnt = error_cnt + 1
204213 end if
205- call json_create_object(escaped_string,' escaped string' )
206- if (json_failed()) then
207- call json_print_error_message(error_unit)
208- error_cnt = error_cnt + 1
209- end if
210- call json_add(escaped_string,' escaped string' ,&
211- ' \/' // &
212- achar (8 )// &
213- achar (12 )// &
214- achar (10 )// &
215- achar (13 )// &
216- achar (9 ))
217- if (json_failed()) then
218- call json_print_error_message(error_unit)
219- error_cnt = error_cnt + 1
220- end if
221-
222214 call json_add(root,a)
223215 if (json_failed()) then
224216 call json_print_error_message(error_unit)
@@ -244,14 +236,23 @@ subroutine test_7(error_cnt)
244236 call json_print_error_message(error_unit)
245237 error_cnt = error_cnt + 1
246238 end if
247- call json_add(root,escaped_string)
239+ call json_add(root,' escaped string' ,&
240+ ' \/' // &
241+ achar (8 )// &
242+ achar (12 )// &
243+ achar (10 )// &
244+ achar (13 )// &
245+ achar (9 ))
248246 if (json_failed()) then
249247 call json_print_error_message(error_unit)
250248 error_cnt = error_cnt + 1
251249 end if
252-
253250 call json_add(root,' wacky string' ,[' trim ' ,' and ' ,' adjust' ,' left' ],&
254251 trim_str= .true. ,adjustl_str= .true. )
252+ if (json_failed()) then
253+ call json_print_error_message(error_unit)
254+ error_cnt = error_cnt + 1
255+ end if
255256
256257 nullify(a) ! don't need these anymore
257258 nullify(b)
@@ -269,10 +270,17 @@ subroutine test_7(error_cnt)
269270 end if
270271 ! look for the 'escaped string' entry
271272 call json_get(root,' escaped string' ,escaped_string,found)
272- if (.not. found) then
273+ if (json_failed() .or. .not. found) then
274+ call json_print_error_message(error_unit)
275+ error_cnt = error_cnt + 1
276+ end if
277+ call json_get(escaped_string,string)
278+ if (json_failed()) then
273279 call json_print_error_message(error_unit)
274280 error_cnt = error_cnt + 1
275281 end if
282+ write (error_unit,' (A)' ) " Fetched unescaped 'escaped string': " // string
283+
276284 ! remove the escaped string entry
277285 if (found) call json_remove(escaped_string,destroy= .true. )
278286 call json_print(root,error_unit) ! print to stderr
0 commit comments