Skip to content

Commit 3a25be4

Browse files
committed
Merge pull request #195 from jacobwilliams/coverage-increases
updating unit tests for coverage increases.
2 parents d1773b9 + ba6870f commit 3a25be4

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

src/tests/jf_test_15.f90

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ subroutine test_15(error_cnt)
6666
call file1%info('this path does not exist',found,var_type,n_children)
6767
call file1%initialize()
6868

69+
call file1%check_for_errors(status_ok,error_msg)
70+
call file1%clear_exceptions()
71+
call file1%destroy()
72+
file1 = json_file(p2,json) !constructor
73+
call file1%destroy(destroy_core=.true.)
74+
75+
call json%initialize( verbose=.false.,&
76+
compact_reals=.true.,&
77+
print_signs=.false.,&
78+
real_format='E',&
79+
spaces_per_tab=4,&
80+
strict_type_checking=.true.,&
81+
trailing_spaces_significant=.false.,&
82+
case_sensitive_keys=.true.)
83+
6984
call json%get_child(p2,-99,p) !invalid index
7085
call json%initialize() !clear exceptions
7186

src/tests/jf_test_16.f90

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ subroutine test_16(error_cnt)
112112
write(error_unit,'(A)') 'Error: this should have failed.'
113113
error_cnt = error_cnt + 1
114114
else
115-
write(error_unit,'(A)') 'Success: This operation is not allowed.'
116115
call json%clear_exceptions()
117116
end if
118117
nullify(p1)
@@ -132,6 +131,86 @@ subroutine test_16(error_cnt)
132131
nullify(p1)
133132
nullify(p2)
134133

134+
call json%destroy(p)
135+
136+
!...........................................................................
137+
! other special cases:
138+
139+
!swap first and last items in a list
140+
write(error_unit,'(A)') ''
141+
write(error_unit,'(A)') '.....................................'
142+
write(error_unit,'(A)') ''
143+
write(error_unit,'(A)') 'Original:'
144+
call json%parse(p, '{ "color": "red", "width": 10, "height": 2 }')
145+
if (json%failed()) then
146+
call json%print_error_message(error_unit)
147+
error_cnt = error_cnt + 1
148+
end if
149+
call json%print(p,error_unit)
150+
write(error_unit,'(A)') ''
151+
write(error_unit,'(A)') 'Swap: color <-> height'
152+
call json%get(p,'color',p1)
153+
call json%get(p,'height',p2)
154+
call json%swap(p1,p2)
155+
if (json%failed()) then
156+
call json%print_error_message(error_unit)
157+
error_cnt = error_cnt + 1
158+
end if
159+
call json%print(p,output_unit)
160+
nullify(p1)
161+
nullify(p2)
162+
call json%destroy(p)
163+
164+
!p2 is first child:
165+
write(error_unit,'(A)') ''
166+
write(error_unit,'(A)') '.....................................'
167+
write(error_unit,'(A)') ''
168+
write(error_unit,'(A)') 'Original:'
169+
call json%parse(p, '{ "color": "red", "width": 10, "height": 2 }')
170+
if (json%failed()) then
171+
call json%print_error_message(error_unit)
172+
error_cnt = error_cnt + 1
173+
end if
174+
call json%print(p,error_unit)
175+
write(error_unit,'(A)') ''
176+
write(error_unit,'(A)') 'Swap: width <-> color'
177+
call json%get(p,'width',p1)
178+
call json%get(p,'color',p2)
179+
call json%swap(p1,p2)
180+
if (json%failed()) then
181+
call json%print_error_message(error_unit)
182+
error_cnt = error_cnt + 1
183+
end if
184+
call json%print(p,output_unit)
185+
nullify(p1)
186+
nullify(p2)
187+
call json%destroy(p)
188+
189+
!p2 is last child:
190+
write(error_unit,'(A)') ''
191+
write(error_unit,'(A)') '.....................................'
192+
write(error_unit,'(A)') ''
193+
write(error_unit,'(A)') 'Original:'
194+
call json%parse(p, '{ "color": "red", "width": 10, "height": 2 }')
195+
if (json%failed()) then
196+
call json%print_error_message(error_unit)
197+
error_cnt = error_cnt + 1
198+
end if
199+
call json%print(p,error_unit)
200+
write(error_unit,'(A)') ''
201+
write(error_unit,'(A)') 'Swap: width <-> height'
202+
call json%get(p,'width',p1)
203+
call json%get(p,'height',p2)
204+
call json%swap(p1,p2)
205+
if (json%failed()) then
206+
call json%print_error_message(error_unit)
207+
error_cnt = error_cnt + 1
208+
end if
209+
call json%print(p,output_unit)
210+
nullify(p1)
211+
nullify(p2)
212+
call json%destroy(p)
213+
135214
end subroutine test_16
136215

137216
end module jf_test_16_mod

0 commit comments

Comments
 (0)