Skip to content

Commit 997e4f9

Browse files
committed
Merge pull request #112 from zbeekman/documentation-fixes
Documentation fixes & coverage improvements
2 parents 25780a9 + c345f06 commit 997e4f9

File tree

4 files changed

+69
-49
lines changed

4 files changed

+69
-49
lines changed

CONTRIBUTING.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ Looking to contribute something to [json-fortran](README.md)? **Here's how you c
3232
## Outstanding Work
3333

3434
- Take a look at the [issues](https://github.com/jacobwilliams/json-fortran/issues) to see if there is an issue you'd like to help address. [Issues](https://github.com/jacobwilliams/json-fortran/issues) with the [ready label](https://github.com/jacobwilliams/json-fortran/issues?q=is%3Aopen+is%3Aissue+label%3A%22ready%22) or in the [ready column on waffle.io](https://waffle.io/jacobwilliams/json-fortran) are issues that are ready to be dealt with. (i.e., They are not blocked by other dependencies and are higher priority.)
35+
- Increasing the test coverage is another helpful way to
36+
contribute. Please take a look at
37+
[this wiki page](https://github.com/jacobwilliams/json-fortran/wiki/Coverage-Analysis)
38+
for a list of uncovered procedures, and at the
39+
[Codecov.io suggestions page](https://codecov.io/github/jacobwilliams/json-fortran/features/suggestions)
40+
to find procedures and lines of code that are still uncovered by the
41+
[unit tests](https://github.com/jacobwilliams/json-fortran/tree/master/src/tests). It
42+
is worth pointing out that the majority of uncovered procedures are
43+
internal, overloaded procedures and can only be exercised by calling
44+
the corresponding generic procedure with input arguments that will
45+
resolve to the specific procedure in question. Let's keep the
46+
following graph trending upwards!
47+
![Codecov.io](http://codecov.io/github/jacobwilliams/json-fortran/branch.svg?branch=master)
3548

3649
[top](#contributing-to-json-fortran)
3750
## Pull Requests
@@ -40,7 +53,7 @@ Looking to contribute something to [json-fortran](README.md)? **Here's how you c
4053
- Pull requests should address one issue at a time, and each commit should be a set of self contained, related changes. If you forget something in a commit, please use `git rebase -i <ref>^` to amend and/or squash erroneous commits. Here `<ref>` is the reference to to oldest commit needing to be modified (SHA, or `HEAD~4`, etc.)
4154
- Each commit should compile, and ideally pass the tests. Very complicated new features or fixes, may have commits that don't pass tests, if otherwise the commit history would include far to many changes in any given commit. Use an interactive rebase to fix any of these issues, as described above.
4255
- Pull requests should always be based on the upstream master,
43-
jacobwilliams/json-fortran:master. Please `rebase` your branch on top
56+
`jacobwilliams/json-fortran:master`. Please `rebase` your branch on top
4457
of the latest upstream master. Assuming you are on your branch and you've added the upstream remote by running something like:
4558
```
4659
git remote add upstream git://github.com/jacobwilliams/json-fortran.git
@@ -60,6 +73,19 @@ git rebase upstream/master
6073
- Each commit should address a single logical change and code base transformation.
6174
- Each commit **must** compile.
6275
- Each commit should pass the tests unless the feature being implemented or bug being fixed requires extensive changes that would result in a commit with too many different changes.
76+
- Each pull request should ensure that the proper unit tests have
77+
been added to cover at least 90% of new or changed code and that the
78+
overall coverage continues to increase.
79+
- New tests are added to the `src/tests` directory and are named
80+
`jf_test_<#>.[Ff]90`. Each test is a stand alone Fortran program
81+
which will automatically be compiled and linked against the
82+
json-fortran library so long as it follows this naming
83+
convention. If any of the tests fail, the test program should exit
84+
with a non-zero return status, using the `stop 2` intrinsic
85+
statement. (The Fortran standard does not require the 'processor' to
86+
have or set a return value, but in practice all compilers respect
87+
this convention. An integer other than `2` may be used, so long as
88+
it is non-zero and supported by the processor.)
6389
- No extraneous white spaces are allowed to be introduced at line endings and all non binary files should end with a single new line. Run `git config core.whitespace trailing-space,space-before-tab,blank-at-eol,blank-at-eof` to setup the whitespace rules from within your fork, and then check for white space errors with `git diff --check` to see if you have accidentally introduced white space errors before committing. (You can also enable the sample `pre-commit` hook that ships with git, to prevent you from committing changes that introduce white space errors. See [this stackoverflow question](http://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-whitespace-before-committing/28446440)) for some tips on preventing the introduction of whitespace errors.
6490
- Please adhere to the code indentation and formatting as it currently exists, aligning common elements vertically, etc. Tab characters are not allowed. Indentations should be done with *4* space characters.
6591
- *Do NOT* allow your editor to make a bunch of indentation or white space changes, that will introduce non-substantive changes on lines that you have not actually edited.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ __NEWS:__ As of June 7, 2015,
5454
downloaded and installed with the [homebrew](https://brew.sh) package
5555
manager on Mac OS X. Once [homebrew](https://brew.sh) is installed,
5656
make sure that the formulae are up to date, view the package options
57-
and caveates, and install the
57+
and caveats, and install the
5858
[json-fortran formula](http://braumeister.org/formula/json-fortran):
5959

6060
```bash
@@ -170,7 +170,7 @@ Reading JSON from a string
170170
---------------
171171
JSON can also be read directly from a character string like so:
172172
```fortran
173-
call json%load_from_string('{"name", "Leonidas"}')
173+
call json%load_from_string('{"name": "Leonidas"}')
174174
```
175175

176176
Modifying variables in a JSON file
@@ -281,7 +281,7 @@ The API documentation for the latest release version can be found [here](http://
281281
[top](#json-fortran-)
282282
Contributing [![Ready in backlog](https://badge.waffle.io/jacobwilliams/json-fortran.png?label=Ready&title=Ready)](CONTRIBUTING.md)
283283
------------
284-
Want to help? Take a quick look at our [contributing guidelines](CONTRIBUTING.md) then claim something in [the "ready" column on our Waffle.io](https://waffle.io/jacobwilliams/json-fortran) and [Fork. Commit. Pull request.](https://help.github.com/articles/fork-a-repo).
284+
Want to help? Take a quick look at our [contributing guidelines](CONTRIBUTING.md) then claim something in [the "ready" column on our Waffle.io](https://waffle.io/jacobwilliams/json-fortran) and [Fork. Commit. Pull request.](https://help.github.com/articles/fork-a-repo)
285285

286286
[top](#json-fortran-)
287287
License

src/json_module.F90

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7599,32 +7599,6 @@ subroutine parse_string(unit, str, string)
75997599
end subroutine parse_string
76007600
!*****************************************************************************************
76017601

7602-
!*****************************************************************************************
7603-
!.... gfortran bug ..... some problem.....
7604-
!*****************************************************************************************
7605-
pure subroutine add_character_to_string(str,ip,c)
7606-
7607-
implicit none
7608-
7609-
character(kind=CK,len=:),allocatable,intent(inout) :: str
7610-
integer(IK),intent(inout) :: ip
7611-
character(kind=CK,len=1),intent(in) :: c
7612-
7613-
if (allocated(str)) then
7614-
!resize string if necessary:
7615-
if (ip>len(str)) str = str // repeat(space, chunk_size)
7616-
else
7617-
str = repeat(space, chunk_size)
7618-
ip = 1
7619-
end if
7620-
7621-
!append to string:
7622-
str(ip:ip) = c
7623-
ip = ip + 1
7624-
7625-
end subroutine add_character_to_string
7626-
!*****************************************************************************************
7627-
76287602
!*****************************************************************************************
76297603
!****if* json_module/parse_for_chars
76307604
!

src/tests/jf_test_7.f90

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ subroutine test_7(error_cnt)
6363

6464
integer,intent(out) :: error_cnt
6565

66-
type(json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string
66+
type(json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string,p
67+
logical :: found
68+
character(kind=CK,len=1), dimension(:), allocatable :: strvec
69+
character(kind=CK,len=:), allocatable :: string
6770

71+
found=.false.
6872
error_cnt = 0
6973
call json_initialize()
7074
if (json_failed()) then
@@ -140,6 +144,12 @@ subroutine test_7(error_cnt)
140144
call json_print_error_message(error_unit)
141145
error_cnt = error_cnt + 1
142146
end if
147+
call json_get_child(a,'chars',p)
148+
call json_get(p,strvec)
149+
if (json_failed()) then
150+
call json_print_error_message(error_unit)
151+
error_cnt = error_cnt + 1
152+
end if
143153
call json_create_object(c,'c')
144154
if (json_failed()) then
145155
call json_print_error_message(error_unit)
@@ -201,23 +211,6 @@ subroutine test_7(error_cnt)
201211
call json_print_error_message(error_unit)
202212
error_cnt = error_cnt + 1
203213
end if
204-
call json_create_object(escaped_string,'escaped string')
205-
if (json_failed()) then
206-
call json_print_error_message(error_unit)
207-
error_cnt = error_cnt + 1
208-
end if
209-
call json_add(escaped_string,'escaped string',&
210-
'\/'//&
211-
achar(8)//&
212-
achar(12)//&
213-
achar(10)//&
214-
achar(13)//&
215-
achar(9))
216-
if (json_failed()) then
217-
call json_print_error_message(error_unit)
218-
error_cnt = error_cnt + 1
219-
end if
220-
221214
call json_add(root,a)
222215
if (json_failed()) then
223216
call json_print_error_message(error_unit)
@@ -243,7 +236,19 @@ subroutine test_7(error_cnt)
243236
call json_print_error_message(error_unit)
244237
error_cnt = error_cnt + 1
245238
end if
246-
call json_add(root,escaped_string)
239+
call json_add(root,'escaped string',&
240+
'\/'//&
241+
achar(8)//&
242+
achar(12)//&
243+
achar(10)//&
244+
achar(13)//&
245+
achar(9))
246+
if (json_failed()) then
247+
call json_print_error_message(error_unit)
248+
error_cnt = error_cnt + 1
249+
end if
250+
call json_add(root,'wacky string',['trim ',' and ',' adjust',' left'],&
251+
trim_str=.true.,adjustl_str=.true.)
247252
if (json_failed()) then
248253
call json_print_error_message(error_unit)
249254
error_cnt = error_cnt + 1
@@ -263,6 +268,21 @@ subroutine test_7(error_cnt)
263268
call json_print_error_message(error_unit)
264269
error_cnt = error_cnt + 1
265270
end if
271+
! look for the 'escaped string' entry
272+
call json_get(root,'escaped string',escaped_string,found)
273+
if (json_failed() .or. .not. found) then
274+
call json_print_error_message(error_unit)
275+
error_cnt = error_cnt + 1
276+
end if
277+
call json_get(escaped_string,string)
278+
if (json_failed()) then
279+
call json_print_error_message(error_unit)
280+
error_cnt = error_cnt + 1
281+
end if
282+
write(error_unit,'(A)') "Fetched unescaped 'escaped string': "//string
283+
284+
! remove the escaped string entry
285+
if (found) call json_remove(escaped_string,destroy=.true.)
266286
call json_print(root,error_unit) !print to stderr
267287
if (json_failed()) then
268288
call json_print_error_message(error_unit)

0 commit comments

Comments
 (0)