Skip to content

Commit eb26a0c

Browse files
committed
added a test for Issue #488
1 parent 9f79ec1 commit eb26a0c

File tree

4 files changed

+82
-2
lines changed

4 files changed

+82
-2
lines changed

src/tests/jf_test_48.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ subroutine test_48(error_cnt)
3737
call json%initialize()
3838
if (json%failed()) then
3939
call json%print_error_message(error_unit)
40-
error_cnt = error_cnt + 1
40+
error_cnt = error_cnt + 1
4141
end if
4242

4343
write(error_unit,'(A)') 'open file'
@@ -71,7 +71,7 @@ subroutine test_48(error_cnt)
7171
write(error_unit,'(A)') 'Success'
7272
else
7373
write(error_unit,'(A)') 'Failed'
74-
end if
74+
end if
7575

7676
write(error_unit,'(A)') ''
7777

src/tests/jf_test_49.F90

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
!*****************************************************************************************
2+
!>
3+
! Module for the 49th unit test.
4+
5+
module jf_test_49_mod
6+
7+
use json_module, wp => json_RK, IK => json_IK, LK => json_LK, CK => json_CK
8+
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit
9+
10+
implicit none
11+
12+
private
13+
public :: test_49
14+
15+
contains
16+
17+
subroutine test_49(error_cnt)
18+
19+
!! 49th unit test. see Issue #488
20+
21+
implicit none
22+
23+
integer,intent(out) :: error_cnt
24+
25+
type(json_file) :: json
26+
integer :: i !! counter
27+
28+
integer,parameter :: n_repeat = 1000 !! number of time to repeat the test
29+
character(kind=CK,len=*),parameter :: json_string = CK_'{"Substance":[]}' !! string to deserialize
30+
31+
write(error_unit,'(A)') ''
32+
write(error_unit,'(A)') '================================='
33+
write(error_unit,'(A)') ' EXAMPLE 49'
34+
write(error_unit,'(A)') '================================='
35+
write(error_unit,'(A)') ''
36+
37+
error_cnt = 0
38+
39+
do i = 1, n_repeat
40+
call json%deserialize(json_string)
41+
if (json%failed()) then
42+
call json%print_error_message(error_unit)
43+
error_cnt = error_cnt + 1
44+
call json%destroy()
45+
exit
46+
end if
47+
call json%destroy()
48+
end do
49+
50+
if (error_cnt==0) then
51+
write(error_unit,'(A)') 'Success'
52+
else
53+
write(error_unit,'(A)') 'Failed'
54+
end if
55+
56+
write(error_unit,'(A)') ''
57+
58+
end subroutine test_49
59+
60+
end module jf_test_49_mod
61+
!*****************************************************************************************
62+
63+
!*****************************************************************************************
64+
#ifndef INTEGRATED_TESTS
65+
program jf_test_49
66+
67+
use jf_test_49_mod , only: test_49
68+
69+
implicit none
70+
integer :: n_errors
71+
72+
call test_49(n_errors)
73+
if (n_errors /= 0) stop 1
74+
75+
end program jf_test_49
76+
#endif
77+
!*****************************************************************************************

visual_studio/jsonfortrantest/jsonfortrantest.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ program jsonfortrantest
5555
use jf_test_46_mod , only: test_46
5656
use jf_test_47_mod , only: test_47
5757
use jf_test_48_mod , only: test_48
58+
use jf_test_49_mod , only: test_49
5859

5960
implicit none
6061

@@ -110,6 +111,7 @@ program jsonfortrantest
110111
call test_46(n_errors); if (n_errors /= 0) stop 1
111112
call test_47(n_errors); if (n_errors /= 0) stop 1
112113
call test_48(n_errors); if (n_errors /= 0) stop 1
114+
call test_49(n_errors); if (n_errors /= 0) stop 1
113115

114116
end program jsonfortrantest
115117
!*****************************************************************************************

visual_studio/jsonfortrantest/jsonfortrantest.vfproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@
9494
<File RelativePath="..\..\src\tests\jf_test_46.F90"/>
9595
<File RelativePath="..\..\src\tests\jf_test_47.F90"/>
9696
<File RelativePath="..\..\src\tests\jf_test_48.F90"/>
97+
<File RelativePath="..\..\src\tests\jf_test_49.F90"/>
9798
<File RelativePath=".\jsonfortrantest.f90"/></Filter></Files>
9899
<Globals/></VisualStudioProject>

0 commit comments

Comments
 (0)