Skip to content

Commit 1f285e9

Browse files
committed
added alloc string unit test for json_file object.
1 parent bb8573f commit 1f285e9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/tests/jf_test_25.F90

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ subroutine test_25(error_cnt)
2121

2222
type(json_value),pointer :: p, tmp
2323
type(json_core) :: json
24+
type(json_file) :: f
2425
logical(lk) :: found
2526
character(kind=CK,len=:),dimension(:),allocatable :: vec !! array of strings from JSON
2627
integer(ik),dimension(:),allocatable :: ilen !! array of string lengths
@@ -102,6 +103,35 @@ subroutine test_25(error_cnt)
102103
end if
103104
#endif
104105

106+
! test json_file interface
107+
f = json_file(p)
108+
call f%get('str_array', vec, ilen, found)
109+
if (f%failed()) then
110+
call f%print_error_message(error_unit)
111+
error_cnt = error_cnt + 1
112+
end if
113+
if (all(ilen==[1,2,3,5])) then
114+
write(error_unit,'(A)') 'json_file success!'
115+
else
116+
write(error_unit,'(A,1X,*(I5,1X))') 'json_file failed: ', ilen
117+
error_cnt = error_cnt + 1
118+
end if
119+
#ifdef USE_UCS4
120+
! unicode test
121+
f = json_file(p)
122+
call f%get(CDK_'str_array', vec, ilen, found)
123+
if (f%failed()) then
124+
call f%print_error_message(error_unit)
125+
error_cnt = error_cnt + 1
126+
end if
127+
if (all(ilen==[1,2,3,5])) then
128+
write(error_unit,'(A)') 'json_file success!'
129+
else
130+
write(error_unit,'(A,1X,*(I5,1X))') 'json_file failed: ', ilen
131+
error_cnt = error_cnt + 1
132+
end if
133+
#endif
134+
105135
! clean up
106136
write(error_unit,'(A)') ''
107137
write(error_unit,'(A)') 'destroy...'

0 commit comments

Comments
 (0)