diff --git a/.gitignore b/.gitignore index 17cef069d1..4188245d5a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,15 @@ doc/ .sconsign.* files/*.json .cflags.* -visual_studio/*.suo -visual_studio/*.u2d +*.suo +*.u2d +*.user + visual_studio/Debug/ visual_studio/Release/ visual_studio/x64/ +visual_studio/.vs/ +visual_studio/jsonfortranlib/ +visual_studio/jsonfortrantest/Debug/ +visual_studio/jsonfortrantest/Release/ +visual_studio/jsonfortrantest/x64 \ No newline at end of file diff --git a/src/json_file_module.F90 b/src/json_file_module.F90 index ceab4abe7a..0a800df0df 100644 --- a/src/json_file_module.F90 +++ b/src/json_file_module.F90 @@ -339,7 +339,8 @@ subroutine initialize_json_core_in_file(me,verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) + allow_duplicate_keys,& + escape_solidus) implicit none @@ -357,7 +358,8 @@ subroutine initialize_json_core_in_file(me,verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) + allow_duplicate_keys,& + escape_solidus) end subroutine initialize_json_core_in_file !***************************************************************************************** @@ -422,7 +424,8 @@ function initialize_json_file(p,verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) result(file_object) + allow_duplicate_keys,& + escape_solidus) result(file_object) implicit none @@ -442,7 +445,8 @@ function initialize_json_file(p,verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) + allow_duplicate_keys,& + escape_solidus) if (present(p)) file_object%p => p diff --git a/src/json_initialize_arguments.inc b/src/json_initialize_arguments.inc index cedc56c7ca..dcb6caf0f1 100644 --- a/src/json_initialize_arguments.inc +++ b/src/json_initialize_arguments.inc @@ -66,3 +66,11 @@ logical(LK),intent(in),optional :: allow_duplicate_keys !! keys are found, an error is thrown. A call to !! [[json_value_validate]] will also check for !! duplicates. +logical(LK),intent(in),optional :: escape_solidus + !! * If True then the solidus "`/`" is always escaped + !! "`\/`" when serializing JSON + !! * If False [default], then it is not escaped. + !! Note that this option does not affect parsing + !! (both escaped and unescaped are still valid in + !! all cases). + diff --git a/src/json_string_utilities.F90 b/src/json_string_utilities.F90 index 612aa5be20..e4db447d55 100644 --- a/src/json_string_utilities.F90 +++ b/src/json_string_utilities.F90 @@ -293,12 +293,14 @@ end subroutine compact_real_string ! ! Add the escape characters to a string for adding to JSON. - subroutine escape_string(str_in, str_out) + subroutine escape_string(str_in, str_out, escape_solidus) implicit none character(kind=CK,len=*),intent(in) :: str_in character(kind=CK,len=:),allocatable,intent(out) :: str_out + logical(LK),intent(in) :: escape_solidus !! if the solidus (forward slash) + !! is also to be escaped integer(IK) :: i !! counter integer(IK) :: ipos !! accumulated string size @@ -308,20 +310,29 @@ subroutine escape_string(str_in, str_out) #if defined __GFORTRAN__ character(kind=CK,len=:),allocatable :: tmp !! workaround for bug in gfortran 6.1 #endif + logical :: to_be_escaped !! if there are characters to be escaped - character(kind=CK,len=*),parameter :: specials = quotation_mark//& + character(kind=CK,len=*),parameter :: specials_no_slash = quotation_mark//& backslash//& - slash//& bspace//& formfeed//& newline//& carriage_return//& horizontal_tab + character(kind=CK,len=*),parameter :: specials = specials_no_slash//slash + + !Do a quick scan for the special characters, ! if any are present, then process the string, ! otherwise, return the string as is. - if (scan(str_in,specials)>0) then + if (escape_solidus) then + to_be_escaped = scan(str_in,specials)>0 + else + to_be_escaped = scan(str_in,specials_no_slash)>0 + end if + + if (to_be_escaped) then str_out = repeat(space,chunk_size) ipos = 1 @@ -351,9 +362,14 @@ subroutine escape_string(str_in, str_out) str_out(ipos:ipos+1) = backslash//c ipos = ipos + 2 - case(quotation_mark,slash) + case(quotation_mark) str_out(ipos:ipos+1) = backslash//c ipos = ipos + 2 + case(slash) + if (escape_solidus) then + str_out(ipos:ipos+1) = backslash//c + ipos = ipos + 2 + end if case(bspace) str_out(ipos:ipos+1) = '\b' ipos = ipos + 2 diff --git a/src/json_value_module.F90 b/src/json_value_module.F90 index ceeb93e8df..122fbc38cc 100644 --- a/src/json_value_module.F90 +++ b/src/json_value_module.F90 @@ -237,6 +237,13 @@ module json_value_module !! will also check for duplicates. If True !! [default] then no special checks are done + logical(LK) :: escape_solidus = .false. !! If True then the solidus "`/`" is always escaped + !! ("`\/`") when serializing JSON. + !! If False [default], then it is not escaped. + !! Note that this option does not affect parsing + !! (both escaped and unescaped versions are still + !! valid in all cases). + contains private @@ -792,7 +799,8 @@ function initialize_json_core(verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) result(json_core_object) + allow_duplicate_keys,& + escape_solidus) result(json_core_object) implicit none @@ -810,7 +818,8 @@ function initialize_json_core(verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) + allow_duplicate_keys,& + escape_solidus) end function initialize_json_core !***************************************************************************************** @@ -845,7 +854,8 @@ subroutine json_initialize(me,verbose,compact_reals,& path_mode,& path_separator,& compress_vectors,& - allow_duplicate_keys) + allow_duplicate_keys,& + escape_solidus) implicit none @@ -923,6 +933,11 @@ subroutine json_initialize(me,verbose,compact_reals,& me%allow_duplicate_keys = allow_duplicate_keys end if + ! if escaping the forward slash: + if (present(escape_solidus)) then + me%escape_solidus = escape_solidus + end if + !Set the format for real numbers: ! [if not changing it, then it remains the same] @@ -1975,7 +1990,7 @@ recursive subroutine json_value_destroy(json,p,destroy_next) if (associated(child)) then p%children => p%children%next p%n_children = p%n_children - 1 - call json_value_destroy(json,child,.false.) + call json%destroy(child,.false.) else call json%throw_exception('Error in json_value_destroy: '//& 'Malformed JSON linked list') @@ -1986,7 +2001,7 @@ recursive subroutine json_value_destroy(json,p,destroy_next) nullify(child) end if - if (associated(p%next) .and. des_next) call json_value_destroy(json,p%next) + if (associated(p%next) .and. des_next) call json%destroy(p%next) if (associated(p%previous)) nullify(p%previous) if (associated(p%parent)) nullify(p%parent) @@ -2418,7 +2433,6 @@ subroutine json_value_validate(json,p,is_valid,error_msg) logical(LK) :: has_duplicate !! to check for duplicate keys character(kind=CK,len=:),allocatable :: path !! path to duplicate key logical(LK) :: status_ok !! to check for existing exception - logical(LK) :: status_ok2 !! to check for a new exception character(kind=CK,len=:),allocatable :: exception_msg !! error message for an existing exception character(kind=CK,len=:),allocatable :: exception_msg2 !! error message for a new exception @@ -5257,7 +5271,7 @@ recursive subroutine json_value_print(json,p,iunit,str,indent,& ! print the name if (allocated(element%name)) then - call escape_string(element%name,str_escaped) + call escape_string(element%name,str_escaped,json%escape_solidus) if (json%no_whitespace) then !compact printing - no extra space call write_it(repeat(space, spaces)//quotation_mark//& @@ -5384,7 +5398,7 @@ recursive subroutine json_value_print(json,p,iunit,str,indent,& if (allocated(p%str_value)) then ! have to escape the string for printing: - call escape_string(p%str_value,str_escaped) + call escape_string(p%str_value,str_escaped,json%escape_solidus) call write_it( s//quotation_mark// & str_escaped//quotation_mark, & comma=print_comma, & @@ -6863,7 +6877,7 @@ subroutine add_to_path(str,path_sep) !! prepend the string to the path implicit none character(kind=CK,len=*),intent(in) :: str !! string to prepend to `path` - character(kind=CK,len=1),intent(in),optional :: path_sep + character(kind=CK,len=*),intent(in),optional :: path_sep !! path separator (default is '.'). !! (ignored if `json%path_mode/=1`) @@ -7678,7 +7692,7 @@ subroutine json_get_string(json, me, value) value = me%str_value else ! return the escaped version: - call escape_string(me%str_value, value) + call escape_string(me%str_value, value, json%escape_solidus) end if else call json%throw_exception('Error in json_get_string: '//& diff --git a/src/tests/jf_test_1.f90 b/src/tests/jf_test_1.f90 index 553cf8ebc7..450b9c3122 100644 --- a/src/tests/jf_test_1.f90 +++ b/src/tests/jf_test_1.f90 @@ -488,6 +488,7 @@ end subroutine print_json_variable end module jf_test_1_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_1 @@ -502,3 +503,4 @@ program jf_test_1 end program jf_test_1 !***************************************************************************************** +#endif diff --git a/src/tests/jf_test_10.f90 b/src/tests/jf_test_10.f90 index c5a4e2de74..7f31202c1e 100644 --- a/src/tests/jf_test_10.f90 +++ b/src/tests/jf_test_10.f90 @@ -334,6 +334,7 @@ end subroutine test_10 end module jf_test_10_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_10 @@ -348,3 +349,4 @@ program jf_test_10 end program jf_test_10 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_11.F90 b/src/tests/jf_test_11.F90 index 1e8285dc4a..6f21f422ea 100644 --- a/src/tests/jf_test_11.F90 +++ b/src/tests/jf_test_11.F90 @@ -274,6 +274,7 @@ end subroutine test_11 end module jf_test_11_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_11 @@ -288,3 +289,4 @@ program jf_test_11 end program jf_test_11 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_12.f90 b/src/tests/jf_test_12.f90 index 4f6c772be2..6545664e4b 100644 --- a/src/tests/jf_test_12.f90 +++ b/src/tests/jf_test_12.f90 @@ -232,6 +232,7 @@ end subroutine test_12 end module jf_test_12_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_12 @@ -246,3 +247,4 @@ program jf_test_12 end program jf_test_12 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_13.f90 b/src/tests/jf_test_13.f90 index f93d68785c..21b31a5cfa 100644 --- a/src/tests/jf_test_13.f90 +++ b/src/tests/jf_test_13.f90 @@ -62,6 +62,7 @@ end subroutine test_13 end module jf_test_13_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_13 @@ -75,3 +76,4 @@ program jf_test_13 end program jf_test_13 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_14.f90 b/src/tests/jf_test_14.f90 index 29a7db5012..4fcd7b992a 100644 --- a/src/tests/jf_test_14.f90 +++ b/src/tests/jf_test_14.f90 @@ -146,6 +146,7 @@ end subroutine rename end module jf_test_14_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_14 @@ -159,3 +160,4 @@ program jf_test_14 end program jf_test_14 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_15.f90 b/src/tests/jf_test_15.f90 index fefa161bb0..1752f86aab 100644 --- a/src/tests/jf_test_15.f90 +++ b/src/tests/jf_test_15.f90 @@ -98,6 +98,7 @@ end subroutine test_15 end module jf_test_15_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_15 @@ -111,3 +112,4 @@ program jf_test_15 end program jf_test_15 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_16.f90 b/src/tests/jf_test_16.f90 index 4284ae4f60..7f2553d8a8 100644 --- a/src/tests/jf_test_16.f90 +++ b/src/tests/jf_test_16.f90 @@ -216,6 +216,7 @@ end subroutine test_16 end module jf_test_16_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_16 @@ -229,3 +230,4 @@ program jf_test_16 end program jf_test_16 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_17.f90 b/src/tests/jf_test_17.f90 index c0f3bf3f50..dc76f3fd75 100644 --- a/src/tests/jf_test_17.f90 +++ b/src/tests/jf_test_17.f90 @@ -71,6 +71,7 @@ end subroutine test_17 end module jf_test_17_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_17 @@ -84,3 +85,4 @@ program jf_test_17 end program jf_test_17 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_18.f90 b/src/tests/jf_test_18.f90 index 1a7293c86d..753680469b 100644 --- a/src/tests/jf_test_18.f90 +++ b/src/tests/jf_test_18.f90 @@ -101,6 +101,7 @@ end subroutine test_18 end module jf_test_18_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_18 @@ -114,3 +115,4 @@ program jf_test_18 end program jf_test_18 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_19.f90 b/src/tests/jf_test_19.f90 index eea7a2b025..405acbd7a5 100644 --- a/src/tests/jf_test_19.f90 +++ b/src/tests/jf_test_19.f90 @@ -160,6 +160,7 @@ end subroutine test_19 end module jf_test_19_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_19 @@ -175,3 +176,4 @@ program jf_test_19 end program jf_test_19 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_2.f90 b/src/tests/jf_test_2.f90 index e8c1e1d748..1fbcaaaad5 100644 --- a/src/tests/jf_test_2.f90 +++ b/src/tests/jf_test_2.f90 @@ -395,6 +395,7 @@ end module jf_test_2_mod !***************************************************************************************** !***************************************************************************************** +#ifndef INTERGATED_TESTS program jf_test_2 !! Second unit test. @@ -407,4 +408,5 @@ program jf_test_2 if (n_errors /= 0) stop 1 end program jf_test_2 +#endif !***************************************************************************************** diff --git a/src/tests/jf_test_20.f90 b/src/tests/jf_test_20.f90 index 608fb96e0d..b0ba2f1521 100644 --- a/src/tests/jf_test_20.f90 +++ b/src/tests/jf_test_20.f90 @@ -197,6 +197,7 @@ end subroutine test_20 end module jf_test_20_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_20 @@ -212,3 +213,4 @@ program jf_test_20 end program jf_test_20 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_21.f90 b/src/tests/jf_test_21.f90 index 407ad49c61..a4cb627cde 100644 --- a/src/tests/jf_test_21.f90 +++ b/src/tests/jf_test_21.f90 @@ -74,6 +74,7 @@ end subroutine test_21 end module jf_test_21_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_21 @@ -87,3 +88,4 @@ program jf_test_21 end program jf_test_21 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_22.f90 b/src/tests/jf_test_22.f90 index 0df6251af4..6e6f4ad520 100644 --- a/src/tests/jf_test_22.f90 +++ b/src/tests/jf_test_22.f90 @@ -76,6 +76,7 @@ end subroutine test_22 end module jf_test_22_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_22 @@ -90,3 +91,4 @@ program jf_test_22 end program jf_test_22 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_23.f90 b/src/tests/jf_test_23.f90 index d92dfb1419..0135c1c60c 100644 --- a/src/tests/jf_test_23.f90 +++ b/src/tests/jf_test_23.f90 @@ -289,6 +289,7 @@ end subroutine test_23 end module jf_test_23_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_23 @@ -303,3 +304,4 @@ program jf_test_23 end program jf_test_23 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_24.F90 b/src/tests/jf_test_24.F90 index 58baaa8cfe..76a5f8db18 100644 --- a/src/tests/jf_test_24.F90 +++ b/src/tests/jf_test_24.F90 @@ -157,6 +157,7 @@ end subroutine test_24 end module jf_test_24_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_24 @@ -171,3 +172,4 @@ program jf_test_24 end program jf_test_24 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_25.F90 b/src/tests/jf_test_25.F90 index 39dded872c..3a2bd83545 100644 --- a/src/tests/jf_test_25.F90 +++ b/src/tests/jf_test_25.F90 @@ -146,6 +146,7 @@ end subroutine test_25 end module jf_test_25_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_25 @@ -160,3 +161,4 @@ program jf_test_25 end program jf_test_25 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_26.f90 b/src/tests/jf_test_26.f90 index 2b69af56ff..03a16f021f 100644 --- a/src/tests/jf_test_26.f90 +++ b/src/tests/jf_test_26.f90 @@ -64,6 +64,7 @@ end subroutine test_26 end module jf_test_26_mod +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_26 @@ -78,3 +79,4 @@ program jf_test_26 end program jf_test_26 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_27.f90 b/src/tests/jf_test_27.f90 index 88216bb9ef..e4804cd327 100644 --- a/src/tests/jf_test_27.f90 +++ b/src/tests/jf_test_27.f90 @@ -79,6 +79,7 @@ end subroutine test_27 end module jf_test_27_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_27 @@ -93,3 +94,4 @@ program jf_test_27 end program jf_test_27 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_29.f90 b/src/tests/jf_test_29.f90 index 55c183a8b3..652ceeb0f8 100644 --- a/src/tests/jf_test_29.f90 +++ b/src/tests/jf_test_29.f90 @@ -139,6 +139,7 @@ end subroutine test_29 end module jf_test_29_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_29 @@ -153,3 +154,4 @@ program jf_test_29 end program jf_test_29 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_3.f90 b/src/tests/jf_test_3.f90 index 8347690664..4c6ea5a117 100644 --- a/src/tests/jf_test_3.f90 +++ b/src/tests/jf_test_3.f90 @@ -138,6 +138,8 @@ end subroutine test_3 end module jf_test_3_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS + !***************************************************************************************** program jf_test_3 @@ -152,3 +154,4 @@ program jf_test_3 end program jf_test_3 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_30.f90 b/src/tests/jf_test_30.f90 new file mode 100644 index 0000000000..f58c36ec7a --- /dev/null +++ b/src/tests/jf_test_30.f90 @@ -0,0 +1,84 @@ +!***************************************************************************************** +!> +! Module for the 30th unit test. + +module jf_test_30_mod + + use json_module, rk => json_rk, lk => json_lk, ik => json_ik, ck => json_ck, cdk => json_cdk + use, intrinsic :: iso_fortran_env , only: error_unit, output_unit + + implicit none + +contains + + subroutine test_30(error_cnt) + + !! Test the `escape_solidus` option. + + implicit none + + integer,intent(out) :: error_cnt + type(json_file) :: json + type(json_core) :: json_c + integer :: i + + character(kind=CK,len=*),parameter :: str = CK_'{"vars":{"a/first":1,"a\/second":2}}' + character(len=*),dimension(2),parameter :: tf = ['True ','False'] + + error_cnt = 0 + + write(error_unit,'(A)') '' + write(error_unit,'(A)') '=================================' + write(error_unit,'(A)') ' TEST 30' + write(error_unit,'(A)') '=================================' + write(error_unit,'(A)') '' + + do i = 1, 2 + + write(error_unit,'(A)') '' + write(error_unit,'(A)') 'escape_solidus = '//trim(tf(i)) + write(error_unit,'(A)') '' + + call json%initialize(escape_solidus=(i==1)) + call json%load_from_string(str) + call json%print_file() + + if (json%failed()) then + call json%print_error_message(error_unit) + error_cnt = error_cnt + 1 + end if + + call json%destroy() + + write(error_unit,'(A)') '' + + end do + + ! do this one just for code coverage: + call json_c%initialize(escape_solidus=.true.) + if (json%failed()) then + call json_c%print_error_message(error_unit) + error_cnt = error_cnt + 1 + end if + + end subroutine test_30 + +end module jf_test_30_mod +!***************************************************************************************** + +#ifndef INTERGATED_TESTS +!***************************************************************************************** +program jf_test_30 + + !! 30th unit test. + + use jf_test_30_mod , only: test_30 + implicit none + integer :: n_errors + n_errors = 0 + call test_30(n_errors) + if (n_errors /= 0) stop 1 + +end program jf_test_30 +!***************************************************************************************** +#endif diff --git a/src/tests/jf_test_4.f90 b/src/tests/jf_test_4.f90 index e3923a2e90..15d5d72e0d 100644 --- a/src/tests/jf_test_4.f90 +++ b/src/tests/jf_test_4.f90 @@ -160,6 +160,7 @@ end subroutine test_4 end module jf_test_4_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_4 @@ -173,3 +174,4 @@ program jf_test_4 if (n_errors /= 0) stop 1 end program jf_test_4 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_5.f90 b/src/tests/jf_test_5.f90 index 18448db414..47a540f064 100644 --- a/src/tests/jf_test_5.f90 +++ b/src/tests/jf_test_5.f90 @@ -105,6 +105,7 @@ end subroutine test_5 end module jf_test_5_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_5 @@ -119,3 +120,4 @@ program jf_test_5 end program jf_test_5 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_6.f90 b/src/tests/jf_test_6.f90 index 79c0e3d661..b60a513d8f 100644 --- a/src/tests/jf_test_6.f90 +++ b/src/tests/jf_test_6.f90 @@ -69,6 +69,7 @@ end subroutine test_6 end module jf_test_6_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_6 @@ -83,3 +84,4 @@ program jf_test_6 end program jf_test_6 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_7.f90 b/src/tests/jf_test_7.f90 index 8136ba30fd..2e5493e959 100644 --- a/src/tests/jf_test_7.f90 +++ b/src/tests/jf_test_7.f90 @@ -260,6 +260,8 @@ end subroutine test_7 end module jf_test_7_mod !***************************************************************************************** + +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_7 @@ -274,3 +276,4 @@ program jf_test_7 end program jf_test_7 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/src/tests/jf_test_8.f90 b/src/tests/jf_test_8.f90 index 05ae46082d..1460732b4a 100644 --- a/src/tests/jf_test_8.f90 +++ b/src/tests/jf_test_8.f90 @@ -126,6 +126,7 @@ end subroutine test_8 end module jf_test_8_mod !***************************************************************************************** +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_8 @@ -140,5 +141,5 @@ program jf_test_8 end program jf_test_8 !***************************************************************************************** - +#endif !******************************************************************************************************* diff --git a/src/tests/jf_test_9.f90 b/src/tests/jf_test_9.f90 index 34e516809e..68440e08a3 100644 --- a/src/tests/jf_test_9.f90 +++ b/src/tests/jf_test_9.f90 @@ -141,7 +141,7 @@ end subroutine read_file end module jf_test_9_mod !***************************************************************************************** - +#ifndef INTERGATED_TESTS !***************************************************************************************** program jf_test_9 @@ -156,3 +156,4 @@ program jf_test_9 end program jf_test_9 !***************************************************************************************** +#endif \ No newline at end of file diff --git a/visual_studio/jsonfortran.sln b/visual_studio/jsonfortran.sln index d849439643..fff4b2230d 100644 --- a/visual_studio/jsonfortran.sln +++ b/visual_studio/jsonfortran.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "jsonfortranlib", "jsonfortranlib\jsonfortranlib.vfproj", "{9A2FEBBE-6702-448E-B361-AE3EA614F5CF}" EndProject +Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "jsonfortrantest", "jsonfortrantest\jsonfortrantest.vfproj", "{6B8385E8-4E5B-4C63-8A06-F2DABE97F304}" + ProjectSection(ProjectDependencies) = postProject + {9A2FEBBE-6702-448E-B361-AE3EA614F5CF} = {9A2FEBBE-6702-448E-B361-AE3EA614F5CF} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -21,6 +26,14 @@ Global {9A2FEBBE-6702-448E-B361-AE3EA614F5CF}.Release|Win32.Build.0 = Release|Win32 {9A2FEBBE-6702-448E-B361-AE3EA614F5CF}.Release|x64.ActiveCfg = Release|x64 {9A2FEBBE-6702-448E-B361-AE3EA614F5CF}.Release|x64.Build.0 = Release|x64 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Debug|Win32.ActiveCfg = Debug|Win32 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Debug|Win32.Build.0 = Debug|Win32 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Debug|x64.ActiveCfg = Debug|x64 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Debug|x64.Build.0 = Debug|x64 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Release|Win32.ActiveCfg = Release|Win32 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Release|Win32.Build.0 = Release|Win32 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Release|x64.ActiveCfg = Release|x64 + {6B8385E8-4E5B-4C63-8A06-F2DABE97F304}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/visual_studio/jsonfortrantest/jsonfortrantest.f90 b/visual_studio/jsonfortrantest/jsonfortrantest.f90 new file mode 100644 index 0000000000..9b640a03a7 --- /dev/null +++ b/visual_studio/jsonfortrantest/jsonfortrantest.f90 @@ -0,0 +1,78 @@ +!***************************************************************************************** +!> +! Entry point for the unified unit test application. +! +! Runs through all the tests in the `tests` folder +! Returns 1 if there are any errors. + + program jsonfortrantest + + use jf_test_1_mod , only: test_1 + use jf_test_2_mod , only: test_2 + use jf_test_3_mod , only: test_3 + use jf_test_4_mod , only: test_4 + use jf_test_5_mod , only: test_5 + use jf_test_6_mod , only: test_6 + use jf_test_7_mod , only: test_7 + use jf_test_8_mod , only: test_8 + use jf_test_9_mod , only: test_9 + use jf_test_10_mod , only: test_10 + use jf_test_11_mod , only: test_11 + use jf_test_12_mod , only: test_12 + use jf_test_13_mod , only: test_13 + use jf_test_14_mod , only: test_14 + use jf_test_15_mod , only: test_15 + use jf_test_16_mod , only: test_16 + use jf_test_17_mod , only: test_17 + use jf_test_18_mod , only: test_18 + use jf_test_19_mod , only: test_19 + use jf_test_20_mod , only: test_20 + use jf_test_21_mod , only: test_21 + use jf_test_22_mod , only: test_22 + use jf_test_23_mod , only: test_23 + use jf_test_24_mod , only: test_24 + use jf_test_25_mod , only: test_25 + use jf_test_26_mod , only: test_26 + use jf_test_27_mod , only: test_27 + use jf_test_29_mod , only: test_29 + use jf_test_30_mod , only: test_30 + + implicit none + + integer :: n_errors !! number of errors + + n_errors = 0 + + call test_1(n_errors); if (n_errors /= 0) stop 1 + call test_2(n_errors); if (n_errors /= 0) stop 1 + call test_3(n_errors); if (n_errors /= 0) stop 1 + call test_4(n_errors); if (n_errors /= 0) stop 1 + call test_5(n_errors); if (n_errors /= 0) stop 1 + call test_6(n_errors); if (n_errors /= 0) stop 1 + call test_7(n_errors); if (n_errors /= 0) stop 1 + call test_8(n_errors); if (n_errors /= 0) stop 1 + call test_9(n_errors); if (n_errors /= 0) stop 1 + call test_10(n_errors); if (n_errors /= 0) stop 1 + call test_11(n_errors); if (n_errors /= 0) stop 1 + call test_12(n_errors); if (n_errors /= 0) stop 1 + call test_13(n_errors); if (n_errors /= 0) stop 1 + call test_14(n_errors); if (n_errors /= 0) stop 1 + call test_15(n_errors); if (n_errors /= 0) stop 1 + call test_16(n_errors); if (n_errors /= 0) stop 1 + call test_17(n_errors); if (n_errors /= 0) stop 1 + call test_18(n_errors); if (n_errors /= 0) stop 1 + call test_19(n_errors); if (n_errors /= 0) stop 1 + call test_20(n_errors); if (n_errors /= 0) stop 1 + call test_21(n_errors); if (n_errors /= 0) stop 1 + call test_22(n_errors); if (n_errors /= 0) stop 1 + call test_23(n_errors); if (n_errors /= 0) stop 1 + call test_24(n_errors); if (n_errors /= 0) stop 1 + call test_25(n_errors); if (n_errors /= 0) stop 1 + call test_26(n_errors); if (n_errors /= 0) stop 1 + call test_27(n_errors); if (n_errors /= 0) stop 1 + call test_29(n_errors); if (n_errors /= 0) stop 1 + call test_30(n_errors); if (n_errors /= 0) stop 1 + + end program jsonfortrantest +!***************************************************************************************** + diff --git a/visual_studio/jsonfortrantest/jsonfortrantest.vfproj b/visual_studio/jsonfortrantest/jsonfortrantest.vfproj new file mode 100644 index 0000000000..ad96bfe25d --- /dev/null +++ b/visual_studio/jsonfortrantest/jsonfortrantest.vfproj @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +