Skip to content

Commit 0d2cf1c

Browse files
committed
added unit test for validate routine.
1 parent f28c72a commit 0d2cf1c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/tests/jf_test_2.f90

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ subroutine test_2(error_cnt)
3232
character(kind=json_CK,len=:),allocatable :: name
3333
integer :: ival,ival_clone
3434
logical :: found
35+
logical :: is_valid
36+
character(kind=json_CK,len=:),allocatable :: error_msg
3537

3638
write(error_unit,'(A)') ''
3739
write(error_unit,'(A)') '================================='
@@ -142,6 +144,15 @@ subroutine test_2(error_cnt)
142144
call add_variables_to_input(json, traj, 'Vz', 'km/s', 'J2000', 'EARTH', [3.0e-3_wp, 30.0e-3_wp, 40.0e-3_wp], error_cnt )
143145
nullify(traj)
144146

147+
!validate it:
148+
write(error_unit,'(A)') ''
149+
write(error_unit,'(A)') 'validating...'
150+
call json%validate(p,is_valid,error_msg)
151+
if (.not. is_valid) then
152+
write(error_unit,'(A)') 'Error: p is not a valid JSON linked list: '//error_msg
153+
error_cnt = error_cnt + 1
154+
end if
155+
145156
write(error_unit,'(A)') ''
146157
write(error_unit,'(A)') 'writing file '//trim(dir//filename2)//'...'
147158

0 commit comments

Comments
 (0)