Skip to content

Commit 7124759

Browse files
committed
added a few more unit tests.
1 parent a237259 commit 7124759

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/tests/jf_test_1.f90

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ subroutine test_1(error_cnt)
3232
character(kind=json_CK,len=:),allocatable :: cval
3333
real(wp) :: rval
3434
logical :: found
35+
logical :: lval
3536

3637
error_cnt = 0
3738
call json%initialize()
@@ -106,6 +107,7 @@ subroutine test_1(error_cnt)
106107

107108
call json%initialize(path_separator=json_CK_'.') ! reset to normal paths
108109

110+
! get an integer value:
109111
write(error_unit,'(A)') ''
110112
call json%get('version.svn', ival)
111113
if (json%failed()) then
@@ -114,7 +116,20 @@ subroutine test_1(error_cnt)
114116
else
115117
write(error_unit,'(A,I5)') 'version.svn = ',ival
116118
end if
119+
! integer to double conversion:
120+
call json%get('version.svn', rval)
121+
if (json%failed()) then
122+
call json%print_error_message(error_unit)
123+
error_cnt = error_cnt + 1
124+
end if
125+
! integer to logical conversion:
126+
call json%get('version.svn', lval)
127+
if (json%failed()) then
128+
call json%print_error_message(error_unit)
129+
error_cnt = error_cnt + 1
130+
end if
117131

132+
! get a character value:
118133
write(error_unit,'(A)') ''
119134
call json%get('data(1).array(2)', cval)
120135
if (json%failed()) then
@@ -124,6 +139,21 @@ subroutine test_1(error_cnt)
124139
write(error_unit,'(A)') 'data(1).array(2) = '//trim(cval)
125140
end if
126141

142+
! get a logical value:
143+
call json%get('data(1).tf1', lval)
144+
if (json%failed()) then
145+
call json%print_error_message(error_unit)
146+
error_cnt = error_cnt + 1
147+
else
148+
write(error_unit,'(A)') 'data(1).tf1 = ', lval
149+
end if
150+
! logical to double:
151+
call json%get('data(1).tf1', rval)
152+
if (json%failed()) then
153+
call json%print_error_message(error_unit)
154+
error_cnt = error_cnt + 1
155+
end if
156+
127157
write(error_unit,'(A)') ''
128158
call json%get('files(1)', cval)
129159
if (json%failed()) then

0 commit comments

Comments
 (0)