Skip to content

Commit 9a15565

Browse files
committed
added unit test for escape_solidus option.
1 parent 47009e4 commit 9a15565

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

src/tests/jf_test_30.f90

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
!*****************************************************************************************
2+
!>
3+
! Module for the 30th unit test.
4+
5+
module jf_test_30_mod
6+
7+
use json_module, rk => json_rk, lk => json_lk, ik => json_ik, ck => json_ck, cdk => json_cdk
8+
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit
9+
10+
implicit none
11+
12+
contains
13+
14+
subroutine test_30(error_cnt)
15+
16+
!! Test the `escape_solidus` option.
17+
18+
implicit none
19+
20+
integer,intent(out) :: error_cnt
21+
type(json_file) :: json
22+
type(json_core) :: json_c
23+
integer :: i
24+
25+
character(kind=CK,len=*),parameter :: str = CK_'{"vars":{"a/first":1,"a\/second":2}}'
26+
character(len=*),dimension(2),parameter :: tf = ['True ','False']
27+
28+
error_cnt = 0
29+
30+
write(error_unit,'(A)') ''
31+
write(error_unit,'(A)') '================================='
32+
write(error_unit,'(A)') ' TEST 30'
33+
write(error_unit,'(A)') '================================='
34+
write(error_unit,'(A)') ''
35+
36+
do i = 1, 2
37+
38+
write(error_unit,'(A)') ''
39+
write(error_unit,'(A)') 'escape_solidus = '//trim(tf(i))
40+
write(error_unit,'(A)') ''
41+
42+
call json%initialize(escape_solidus=(i==1))
43+
call json%load_from_string(str)
44+
call json%print_file()
45+
46+
if (json%failed()) then
47+
call json%print_error_message(error_unit)
48+
error_cnt = error_cnt + 1
49+
end if
50+
51+
call json%destroy()
52+
53+
write(error_unit,'(A)') ''
54+
55+
end do
56+
57+
! do this one just for code coverage:
58+
call json_c%initialize(escape_solidus=.true.)
59+
if (json%failed()) then
60+
call json_c%print_error_message(error_unit)
61+
error_cnt = error_cnt + 1
62+
end if
63+
64+
end subroutine test_30
65+
66+
end module jf_test_30_mod
67+
!*****************************************************************************************
68+
69+
!*****************************************************************************************
70+
program jf_test_30
71+
72+
!! 30th unit test.
73+
74+
use jf_test_30_mod , only: test_30
75+
implicit none
76+
integer :: n_errors
77+
n_errors = 0
78+
call test_30(n_errors)
79+
if (n_errors /= 0) stop 1
80+
81+
end program jf_test_30
82+
!*****************************************************************************************

0 commit comments

Comments
 (0)