Skip to content

Commit e0577fc

Browse files
committed
adding some additional unit tests.
1 parent 04d3446 commit e0577fc

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/tests/jf_test_24.f90

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ subroutine test_24(error_cnt)
2020
integer,intent(out) :: error_cnt
2121

2222
type(json_value),pointer :: p
23-
type(json_value),pointer :: tmp
2423
type(json_core) :: json
2524
logical(lk) :: found
25+
logical(lk) :: was_created
2626
logical(lk) :: is_valid
2727
character(kind=CK,len=:),allocatable :: error_msg
2828

@@ -55,7 +55,23 @@ subroutine test_24(error_cnt)
5555
call json%add_by_path(p,'a.aa.aaaa(3)' , 4.0_rk , found)
5656
call json%add_by_path(p,'a.array(1)' , 5 , found)
5757
call json%add_by_path(p,'a.array(2).scalar' , '6' , found)
58-
call json%add_by_path(p,'a.array(2).logical', .true. , found)
58+
call json%add_by_path(p,'a.array(2).logical', .true. , found, was_created)
59+
60+
if (.not. was_created) then
61+
write(error_unit,'(A)') 'Error: variable should have been created.'
62+
error_cnt = error_cnt + 1
63+
end if
64+
65+
! now for variables that are already present:
66+
call json%add_by_path(p,'a.aa.aaaa(3)' , 40.0_rk , found)
67+
call json%add_by_path(p,'a.array(1)' , 50 , found)
68+
call json%add_by_path(p,'a.array(2).scalar' , '60' , found)
69+
call json%add_by_path(p,'a.array(2).logical', .false. , found, was_created)
70+
71+
if (was_created) then
72+
write(error_unit,'(A)') 'Error: variable should already have been present.'
73+
error_cnt = error_cnt + 1
74+
end if
5975

6076
write(error_unit,'(A)') 'validating...'
6177
call json%validate(p,is_valid,error_msg)

0 commit comments

Comments
 (0)