Skip to content

Commit 1e46b80

Browse files
committed
added unit test for json_value_add_null.
minor correction to json_value_validate: error_msg should have been intent(out)
1 parent 2c96de6 commit 1e46b80

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

files/inputs/test2.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
true,
2020
false,
2121
true
22-
]
22+
],
23+
"null_variable": null
2324
},
2425
"trajectory": [
2526
{

src/json_value_module.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,8 +1945,8 @@ subroutine json_value_validate(json,p,is_valid,error_msg)
19451945
class(json_core),intent(inout) :: json
19461946
type(json_value),pointer,intent(in) :: p
19471947
logical(LK),intent(out) :: is_valid !! True if the structure is valid.
1948-
character(kind=CK,len=:),allocatable :: error_msg !! if not valid, this will contain
1949-
!! a description of the problem
1948+
character(kind=CK,len=:),allocatable,intent(out) :: error_msg !! if not valid, this will contain
1949+
!! a description of the problem
19501950

19511951
if (associated(p)) then
19521952
is_valid = .true.

src/tests/jf_test_2.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ subroutine test_2(error_cnt)
133133
call json%print_error_message(error_unit)
134134
error_cnt = error_cnt + 1
135135
end if
136+
call json%add(inp, 'null_variable')
137+
if (json%failed()) then
138+
call json%print_error_message(error_unit)
139+
error_cnt = error_cnt + 1
140+
end if
136141
nullify(inp)
137142

138143
!trajectory variables:

0 commit comments

Comments
 (0)