Skip to content

Commit 3e2d9f3

Browse files
committed
update unit tests.
fixed an example in the comments, and minor refactoring.
1 parent d14acbf commit 3e2d9f3

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/json_value_module.F90

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ module json_value_module
570570
!````fortran
571571
! type(json_core) :: json
572572
! type(json_value),pointer :: p
573-
! call json%create_integer(p,'value',42)
573+
! call json%create_integer(p,42,'value')
574574
!````
575575
generic,public :: create_integer => MAYBEWRAP(json_value_create_integer)
576576
procedure :: MAYBEWRAP(json_value_create_integer)
@@ -7690,8 +7690,8 @@ subroutine json_value_create_logical(json,p,val,name)
76907690

76917691
class(json_core),intent(inout) :: json
76927692
type(json_value),pointer :: p
7693-
character(kind=CK,len=*),intent(in) :: name !! variable name
76947693
logical(LK),intent(in) :: val !! variable value
7694+
character(kind=CK,len=*),intent(in) :: name !! variable name
76957695

76967696
call json_value_create(p)
76977697
call to_logical(p,val,name)
@@ -7711,8 +7711,8 @@ subroutine wrap_json_value_create_logical(json,p,val,name)
77117711

77127712
class(json_core),intent(inout) :: json
77137713
type(json_value),pointer :: p
7714-
character(kind=CDK,len=*),intent(in) :: name
77157714
logical(LK),intent(in) :: val
7715+
character(kind=CDK,len=*),intent(in) :: name
77167716

77177717
call json%create_logical(p,val,to_unicode(name))
77187718

@@ -7738,8 +7738,8 @@ subroutine json_value_create_integer(json,p,val,name)
77387738

77397739
class(json_core),intent(inout) :: json
77407740
type(json_value),pointer :: p
7741-
character(kind=CK,len=*),intent(in) :: name
77427741
integer(IK),intent(in) :: val
7742+
character(kind=CK,len=*),intent(in) :: name
77437743

77447744
call json_value_create(p)
77457745
call to_integer(p,val,name)
@@ -7760,8 +7760,8 @@ subroutine wrap_json_value_create_integer(json,p,val,name)
77607760

77617761
class(json_core),intent(inout) :: json
77627762
type(json_value),pointer :: p
7763-
character(kind=CDK,len=*),intent(in) :: name
77647763
integer(IK),intent(in) :: val
7764+
character(kind=CDK,len=*),intent(in) :: name
77657765

77667766
call json%create_integer(p,val,to_unicode(name))
77677767

@@ -7787,8 +7787,8 @@ subroutine json_value_create_double(json,p,val,name)
77877787

77887788
class(json_core),intent(inout) :: json
77897789
type(json_value),pointer :: p
7790-
character(kind=CK,len=*),intent(in) :: name
77917790
real(RK),intent(in) :: val
7791+
character(kind=CK,len=*),intent(in) :: name
77927792

77937793
call json_value_create(p)
77947794
call to_double(p,val,name)
@@ -7809,8 +7809,8 @@ subroutine wrap_json_value_create_double(json,p,val,name)
78097809

78107810
class(json_core),intent(inout) :: json
78117811
type(json_value),pointer :: p
7812-
character(kind=CDK,len=*),intent(in) :: name
78137812
real(RK),intent(in) :: val
7813+
character(kind=CDK,len=*),intent(in) :: name
78147814

78157815
call json%create_double(p,val,to_unicode(name))
78167816

@@ -7836,8 +7836,8 @@ subroutine json_value_create_string(json,p,val,name)
78367836

78377837
class(json_core),intent(inout) :: json
78387838
type(json_value),pointer :: p
7839-
character(kind=CK,len=*),intent(in) :: name
78407839
character(kind=CK,len=*),intent(in) :: val
7840+
character(kind=CK,len=*),intent(in) :: name
78417841

78427842
call json_value_create(p)
78437843
call to_string(p,val,name)
@@ -7858,8 +7858,8 @@ subroutine wrap_json_value_create_string(json,p,val,name)
78587858

78597859
class(json_core),intent(inout) :: json
78607860
type(json_value),pointer :: p
7861-
character(kind=CDK,len=*),intent(in) :: name
78627861
character(kind=CDK,len=*),intent(in) :: val
7862+
character(kind=CDK,len=*),intent(in) :: name
78637863

78647864
call json%create_string(p,to_unicode(val),to_unicode(name))
78657865

src/tests/jf_test_26.f90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ subroutine test_26(error_cnt)
1414
integer,intent(out) :: error_cnt
1515

1616
type(json_core) :: json
17-
type(json_value),pointer :: p
17+
type(json_value),pointer :: p,tmp
1818
type(json_file) :: f
1919
logical(lk) :: is_valid
2020
character(kind=CK,len=:),allocatable :: error_msg
@@ -40,6 +40,12 @@ subroutine test_26(error_cnt)
4040
call f%add(cdk_'test.vector.unicode(3)', [ck_'cdk, ck'])
4141
call f%add(cdk_'test.vector.unicode(4)', [cdk_'cdk, cdk'])
4242

43+
!add a json_value pointer:
44+
call json%create_integer(tmp,999,'') ! note that the name will be replaced
45+
! with the name given in the path
46+
! when it is added.
47+
call f%add('inputs.pointer',tmp)
48+
4349
write(error_unit,'(A)') 'validating...'
4450
call f%get(p)
4551
call json%validate(p,is_valid,error_msg)

0 commit comments

Comments
 (0)