@@ -170,94 +170,113 @@ subroutine test_46(error_cnt)
170
170
171
171
! unicode:
172
172
call json_f% get(CK_' not_there' , ival, found, default= 99_IK )
173
- if (json % failed() .or. found .or. ival /= 99_IK ) then
173
+ if (json_f % failed() .or. found .or. ival /= 99_IK ) then
174
174
write (error_unit,' (A)' ) ' Error using json_get_integer_by_path default'
175
175
error_cnt = error_cnt + 1
176
176
end if
177
177
178
178
call json_f% get(CK_' not_there' , rval, found, default= 99.0_RK )
179
- if (json % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
179
+ if (json_f % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
180
180
write (error_unit,' (A)' ) ' Error using json_get_real_by_path default'
181
181
error_cnt = error_cnt + 1
182
182
end if
183
183
184
184
call json_f% get(CK_' not_there' , lval, found, default= .true. )
185
- if (json % failed() .or. found .or. lval .neqv. .true. ) then
185
+ if (json_f % failed() .or. found .or. lval .neqv. .true. ) then
186
186
write (error_unit,' (A)' ) ' Error using json_get_logical_by_path default'
187
187
error_cnt = error_cnt + 1
188
188
end if
189
189
190
190
call json_f% get(CK_' not_there' , cval, found, default= CK_' default' )
191
- if (json % failed() .or. found .or. cval /= CK_' default' ) then
191
+ if (json_f % failed() .or. found .or. cval /= CK_' default' ) then
192
192
write (error_unit,' (A)' ) ' Error using json_get_string_by_path default'
193
193
error_cnt = error_cnt + 1
194
194
end if
195
195
196
196
call json_f% get(CK_' not_there' , cvec, found, default= cvec_default)
197
- if (json % failed() .or. found .or. any (cvec /= cvec_default)) then
197
+ if (json_f % failed() .or. found .or. any (cvec /= cvec_default)) then
198
198
write (error_unit,' (A)' ) ' Error using json_get_string_vec_by_path default'
199
199
error_cnt = error_cnt + 1
200
200
end if
201
201
call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default)
202
- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
202
+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
203
203
write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
204
204
error_cnt = error_cnt + 1
205
205
end if
206
206
call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default, default_ilen= ilen_default)
207
- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
207
+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
208
208
write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
209
209
error_cnt = error_cnt + 1
210
210
end if
211
211
212
212
! default:
213
213
call json_f% get(' not_there' , ival, found, default= 99_IK )
214
- if (json % failed() .or. found .or. ival /= 99_IK ) then
214
+ if (json_f % failed() .or. found .or. ival /= 99_IK ) then
215
215
write (error_unit,' (A)' ) ' Error using json_get_integer_by_path default'
216
216
error_cnt = error_cnt + 1
217
217
end if
218
218
219
219
call json_f% get(' not_there' , rval, found, default= 99.0_RK )
220
- if (json % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
220
+ if (json_f % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
221
221
write (error_unit,' (A)' ) ' Error using json_get_real_by_path default'
222
222
error_cnt = error_cnt + 1
223
223
end if
224
224
225
225
call json_f% get(' not_there' , lval, found, default= .true. )
226
- if (json % failed() .or. found .or. lval .neqv. .true. ) then
226
+ if (json_f % failed() .or. found .or. lval .neqv. .true. ) then
227
227
write (error_unit,' (A)' ) ' Error using json_get_logical_by_path default'
228
228
error_cnt = error_cnt + 1
229
229
end if
230
230
231
231
call json_f% get(' not_there' , cval, found, default= CK_' default' )
232
- if (json % failed() .or. found .or. cval /= CK_' default' ) then
232
+ if (json_f % failed() .or. found .or. cval /= CK_' default' ) then
233
233
write (error_unit,' (A)' ) ' Error using json_get_string_by_path default'
234
234
error_cnt = error_cnt + 1
235
235
end if
236
236
237
237
call json_f% get(' not_there' , cvec, found, default= cvec_default)
238
- if (json % failed() .or. found .or. any (cvec /= cvec_default)) then
238
+ if (json_f % failed() .or. found .or. any (cvec /= cvec_default)) then
239
239
write (error_unit,' (A)' ) ' Error using json_get_string_vec_by_path default'
240
240
error_cnt = error_cnt + 1
241
241
end if
242
242
call json_f% get(' not_there' , cvec2, ilen, found, default= cvec_default)
243
- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
243
+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
244
244
write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
245
245
error_cnt = error_cnt + 1
246
246
end if
247
247
call json_f% get(' not_there' , cvec2, ilen, found, default= cvec_default, default_ilen= ilen_default)
248
- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
248
+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
249
249
write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
250
250
error_cnt = error_cnt + 1
251
251
end if
252
252
253
- ! now, we try them when an exception is active:
254
253
call json_f% destroy()
255
- json_f = json_file(CK_' {"x": 1.0e.2.1}' ) ! this will raise an exception
254
+
255
+ json_f = str ! this should succeed
256
+ if (json_f% failed()) then
257
+ write (error_unit,' (A)' ) ' Error in json_file = string assignment operator'
258
+ error_cnt = error_cnt + 1
259
+ end if
260
+
261
+ ! now, we try them when an exception is active:
262
+ json_f = CK_' {"x": 1.0e.2.1}' ! this will raise an exception
263
+ if (.not. json_f% failed()) then
264
+ write (error_unit,' (A)' ) ' Error in json_file = string assignment operator : ' // &
265
+ ' should have raised an exception'
266
+ error_cnt = error_cnt + 1
267
+ end if
268
+
256
269
call json_f% get(CK_' not_there' , rval, found, default= 99.0_RK )
257
270
call json_f% get(CK_' not_there' , cvec, found, default= [CK_' 1' ])
258
271
call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default)
259
272
call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default, default_ilen= ilen_default)
260
273
274
+ json_f = str ! now, try again after a failure
275
+ if (json_f% failed()) then
276
+ write (error_unit,' (A)' ) ' Error in json_file = string assignment operator'
277
+ error_cnt = error_cnt + 1
278
+ end if
279
+
261
280
if (error_cnt== 0 ) then
262
281
write (error_unit,' (A)' ) ' Success!'
263
282
else
0 commit comments