Skip to content

Commit 08cce19

Browse files
committed
Merge pull request #65 from jacobwilliams/unit-tests
Unit test updates
2 parents 13ff167 + 5f586dd commit 08cce19

10 files changed

+125
-128
lines changed

deploy.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ if [ ! "$TRAVIS" ]; then #not on travis, try a sane deploy of current branch's d
1818
cd gh-pages
1919
[ -e "$BRANCH" ] && rm -r "$BRANCH" # wipe out old docs if they exist
2020
mkdir "$BRANCH"
21-
for f in ../documentation/*.*; do # add branch info to header and clean line endings
22-
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$BRANCH"'</a>;' $f | sed 's/ *$//' > "$BRANCH/${f##*/}"
21+
mkdir "$BRANCH/tests"
22+
FILES=$(find ../documentation -name '*.*') #get all the files (including in subdirectories)
23+
for f in $FILES; do # add branch info to header and clean line endings
24+
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$BRANCH"'</a>;' $f | sed 's/ *$//' > "$BRANCH/${f##*documentation/}"
2325
done
2426
git add "$BRANCH"
2527
git commit -m "Development documentation for $BRANCH updated for commit $REVISION"
@@ -39,8 +41,10 @@ else #running under travis
3941
cd gh-pages
4042
[ -e master ] && rm -r master # wipe out docs if they exist
4143
mkdir master
42-
for f in ../documentation/*.*; do # add branch info to header and clean line endings
43-
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran master</a>;' $f | sed 's/ *$//' > master/${f##*/}
44+
mkdir master/tests
45+
FILES=$(find ../documentation -name '*.*') #get all the files (including in subdirectories)
46+
for f in $FILES; do # add branch info to header and clean line endings
47+
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran master</a>;' $f | sed 's/ *$//' > master/${f##*documentation/}
4448
done
4549
git add master
4650
git commit -m "Development documentation updated by travis job $TRAVIS_JOB_NUMBER for commits $TRAVIS_COMMIT_RANGE"
@@ -52,10 +56,12 @@ else #running under travis
5256
cd gh-pages
5357
[ -e "$TRAVIS_TAG" ] && rm -r "$TRAVIS_TAG" # wipe out existing docs for tag if they exist
5458
mkdir "$TRAVIS_TAG"
59+
mkdir "$TRAVIS_TAG/tests"
5560
# Add an entry in index.html for the new tag, assume none exists
5661
awk '/<!--Next stable release goes here-->/{print "<a href=\"./'"$TRAVIS_TAG"'/masterindex.html\" class=\"indexitem\" >'"$TRAVIS_TAG"'</a>"}1' index.html > index2.html && mv index2.html index.html
57-
for f in ../documentation/*.*; do # add tag info to headers and clean line endings
58-
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$TRAVIS_TAG"'</a>;' $f | sed 's/ *$//' > "$TRAVIS_TAG/${f##*/}"
62+
FILES=$(find ../documentation -name '*.*') #get all the files (including in subdirectories)
63+
for f in $FILES; do # add tag info to headers and clean line endings
64+
sed '/[^#]robo_top_of_doc/ s;jsonfortran</a>;jsonfortran '"$TRAVIS_TAG"'</a>;' $f | sed 's/ *$//' > "$TRAVIS_TAG/${f##*documentation/}"
5965
done
6066
git add "$TRAVIS_TAG" index.html # don't forget to add the top level index!
6167
git commit -m "Tag/release documentation updated by travis job $TRAVIS_JOB_NUMBER for tag $TRAVIS_TAG $TRAVIS_COMMIT"

robodoc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ items:
3232
RESULT
3333
SEE ALSO
3434
USAGE
35+
USES
3536
WARNINGS
3637
source line comments:
3738
!

src/tests/jf_test_1.f90

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
!*******************************************************************************************************
2-
!****f* JSON/test_1
2+
!****u* JSON/jf_test_1
33
!
44
! NAME
5-
! json_test
5+
! jf_test_1
66
!
77
! DESCRIPTION
88
! First unit test
@@ -12,11 +12,11 @@
1212
! iso_fortran_env (intrinsic)
1313
!
1414
! HISTORY
15-
! Izaak Beekman : 2/18/2015 : Created
15+
! Izaak Beekman : 2/18/2015 : Created (refactoried original json_example.f90 file)
1616
!
17-
! COPYRIGHT
17+
! LICENSE
1818
!
19-
! JSON-FORTRAN: A Fortran 2003/2008 JSON API
19+
! JSON-FORTRAN: A Fortran 2008 JSON API
2020
! https://github.com/jacobwilliams/json-fortran
2121
!
2222
! Copyright (c) 2014, Jacob Williams
@@ -47,22 +47,23 @@
4747
! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4848
!
4949
! SOURCE
50+
5051
module jf_test_1_mod
52+
5153
use json_module
5254
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit, wp => real64
55+
5356
implicit none
54-
character(len=*),parameter :: dir = '../files/' !working directory
5557

58+
character(len=*),parameter :: dir = '../files/' !working directory
5659
character(len=*),parameter :: filename1 = 'test1.json'
5760

5861
contains
59-
!**************************************************************
60-
subroutine test_1(error_cnt)
61-
!**************************************************************
62-
!
63-
! Read a sample JSON file and retrieve some data from it
64-
!
65-
!**************************************************************
62+
63+
subroutine test_1(error_cnt)
64+
65+
! Read a sample JSON file and retrieve some data from it
66+
6667
implicit none
6768

6869
integer,intent(out) :: error_cnt
@@ -278,12 +279,9 @@ subroutine test_1(error_cnt)
278279
error_cnt = error_cnt + 1
279280
end if
280281

281-
!**************************************************************
282282
end subroutine test_1
283-
!**************************************************************
284283

285284
end module jf_test_1_mod
286-
!*******************************************************************************************************
287285

288286
program jf_test_1
289287
use jf_test_1_mod , only: test_1
@@ -293,3 +291,5 @@ program jf_test_1
293291
call test_1(n_errors)
294292
if (n_errors /= 0) stop 1
295293
end program jf_test_1
294+
295+
!*******************************************************************************************************

src/tests/jf_test_2.f90

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
!*******************************************************************************************************
2-
!****f* JSON/test_2
2+
!****u* JSON/jf_test_2
33
!
44
! NAME
5-
! json_test
5+
! jf_test_2
66
!
77
! DESCRIPTION
88
! Second unit test
@@ -12,11 +12,11 @@
1212
! iso_fortran_env (intrinsic)
1313
!
1414
! HISTORY
15-
! Izaak Beekman : 2/18/2015 : Created
15+
! Izaak Beekman : 2/18/2015 : Created (refactoried original json_example.f90 file)
1616
!
17-
! COPYRIGHT
17+
! LICENSE
1818
!
19-
! JSON-FORTRAN: A Fortran 2003/2008 JSON API
19+
! JSON-FORTRAN: A Fortran 2008 JSON API
2020
! https://github.com/jacobwilliams/json-fortran
2121
!
2222
! Copyright (c) 2014, Jacob Williams
@@ -47,22 +47,23 @@
4747
! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4848
!
4949
! SOURCE
50+
5051
module jf_test_2_mod
52+
5153
use json_module
5254
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit, wp => real64
55+
5356
implicit none
54-
character(len=*),parameter :: dir = '../files/' !working directory
5557

58+
character(len=*),parameter :: dir = '../files/' !working directory
5659
character(len=*),parameter :: filename2 = 'test2.json'
5760

5861
contains
59-
!**************************************************************
60-
subroutine test_2(error_cnt)
61-
!**************************************************************
62-
!
63-
! Populate a JSON structure and write it to a file.
64-
!
65-
!**************************************************************
62+
63+
subroutine test_2(error_cnt)
64+
65+
! Populate a JSON structure and write it to a file.
66+
6667
implicit none
6768

6869
integer,intent(out) :: error_cnt
@@ -196,15 +197,10 @@ subroutine test_2(error_cnt)
196197

197198
write(error_unit,'(A)') ''
198199

199-
!**************************************************************
200200
end subroutine test_2
201-
!**************************************************************
202201

203-
!**************************************************************
204202
subroutine add_variables_to_input(me, variable, units, frame, center, rdata, error_cnt)
205-
!**************************************************************
206-
! Used by test_2.
207-
!**************************************************************
203+
!Used by test_2.
208204

209205
implicit none
210206

@@ -264,12 +260,9 @@ subroutine add_variables_to_input(me, variable, units, frame, center, rdata, err
264260
!cleanup:
265261
nullify(var)
266262

267-
!**************************************************************
268263
end subroutine add_variables_to_input
269-
!**************************************************************
270264

271265
end module jf_test_2_mod
272-
!*******************************************************************************************************
273266

274267
program jf_test_2
275268
use jf_test_2_mod , only: test_2
@@ -279,3 +272,5 @@ program jf_test_2
279272
call test_2(n_errors)
280273
if (n_errors /= 0) stop 1
281274
end program jf_test_2
275+
276+
!*******************************************************************************************************

src/tests/jf_test_3.f90

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
!*******************************************************************************************************
2-
!****f* JSON/test_3
2+
!****u* JSON/jf_test_3
33
!
44
! NAME
5-
! json_test
5+
! jf_test_3
66
!
77
! DESCRIPTION
88
! Third unit test
@@ -12,11 +12,11 @@
1212
! iso_fortran_env (intrinsic)
1313
!
1414
! HISTORY
15-
! Izaak Beekman : 2/18/2015 : Created
15+
! Izaak Beekman : 2/18/2015 : Created (refactoried original json_example.f90 file)
1616
!
17-
! COPYRIGHT
17+
! LICENSE
1818
!
19-
! JSON-FORTRAN: A Fortran 2003/2008 JSON API
19+
! JSON-FORTRAN: A Fortran 2008 JSON API
2020
! https://github.com/jacobwilliams/json-fortran
2121
!
2222
! Copyright (c) 2014, Jacob Williams
@@ -47,24 +47,23 @@
4747
! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4848
!
4949
! SOURCE
50+
5051
module jf_test_3_mod
52+
5153
use json_module
5254
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit, wp => real64
55+
5356
implicit none
54-
character(len=*),parameter :: dir = '../files/' !working directory
5557

58+
character(len=*),parameter :: dir = '../files/' !working directory
5659
character(len=*),parameter :: filename2 = 'test2.json'
5760

5861
contains
5962

60-
!**************************************************************
6163
subroutine test_3(error_cnt)
62-
!**************************************************************
63-
!
64-
! Read the file generated in test_2, and extract
65-
! some data from it.
66-
!
67-
!**************************************************************
64+
65+
! Read the file generated in jf_test_2, and extract some data from it.
66+
6867
implicit none
6968

7069
integer,intent(out) :: error_cnt
@@ -163,12 +162,9 @@ subroutine test_3(error_cnt)
163162
error_cnt = error_cnt + 1
164163
end if
165164

166-
!**************************************************************
167165
end subroutine test_3
168-
!**************************************************************
169166

170167
end module jf_test_3_mod
171-
!*******************************************************************************************************
172168

173169
program jf_test_3
174170
use jf_test_3_mod , only: test_3
@@ -178,3 +174,5 @@ program jf_test_3
178174
call test_3(n_errors)
179175
if (n_errors /= 0) stop 1
180176
end program jf_test_3
177+
178+
!*******************************************************************************************************

src/tests/jf_test_4.f90

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
!*******************************************************************************************************
2-
!****f* JSON/test_4
2+
!****u* JSON/jf_test_4
33
!
44
! NAME
5-
! json_test
5+
! jf_test_4
66
!
77
! DESCRIPTION
88
! Fourth unit test
@@ -12,11 +12,11 @@
1212
! iso_fortran_env (intrinsic)
1313
!
1414
! HISTORY
15-
! Izaak Beekman : 2/18/2015 : Created
15+
! Izaak Beekman : 2/18/2015 : Created (refactoried original json_example.f90 file)
1616
!
17-
! COPYRIGHT
17+
! LICENSE
1818
!
19-
! JSON-FORTRAN: A Fortran 2003/2008 JSON API
19+
! JSON-FORTRAN: A Fortran 2008 JSON API
2020
! https://github.com/jacobwilliams/json-fortran
2121
!
2222
! Copyright (c) 2014, Jacob Williams
@@ -47,27 +47,28 @@
4747
! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4848
!
4949
! SOURCE
50+
5051
module jf_test_4_mod
52+
5153
use json_module
5254
use, intrinsic :: iso_fortran_env , only: error_unit, output_unit, wp => real64
55+
5356
implicit none
54-
character(len=*),parameter :: dir = '../files/' !working directory
5557

58+
character(len=*),parameter :: dir = '../files/' !working directory
5659
character(len=*),parameter :: filename4 = 'test4.json'
5760

5861
contains
5962

60-
!**************************************************************
63+
6164
subroutine test_4(error_cnt)
62-
!**************************************************************
63-
!
65+
6466
! Populate a JSON structure, write it to a file,
6567
! then read it.
6668
!
6769
! Also tests the json_value_to_string routine to write
6870
! the file to a character string.
69-
!
70-
!**************************************************************
71+
7172
implicit none
7273

7374
integer,intent(out) :: error_cnt
@@ -162,7 +163,6 @@ subroutine test_4(error_cnt)
162163
error_cnt = error_cnt + 1
163164
end if
164165

165-
166166
write(error_unit,'(A)') ''
167167
write(error_unit,'(A)') 'cleanup'
168168
call json%destroy()
@@ -171,12 +171,9 @@ subroutine test_4(error_cnt)
171171
error_cnt = error_cnt + 1
172172
end if
173173

174-
!**************************************************************
175174
end subroutine test_4
176-
!**************************************************************
177175

178176
end module jf_test_4_mod
179-
!*******************************************************************************************************
180177

181178
program jf_test_4
182179
use jf_test_4_mod , only: test_4
@@ -186,3 +183,5 @@ program jf_test_4
186183
call test_4(n_errors)
187184
if (n_errors /= 0) stop 1
188185
end program jf_test_4
186+
187+
!*******************************************************************************************************

0 commit comments

Comments
 (0)