|
| 1 | +!***************************************************************************************** |
| 2 | +!> author: Jacob Williams |
| 3 | +! |
| 4 | +! Module for the 40th unit test. |
| 5 | +! |
| 6 | +! This tests to make sure `stop_on_error` doesn't stop the program |
| 7 | +! for internal exceptions that are not really errors (in this case, |
| 8 | +! when creating structures that don't yet exist). |
| 9 | + |
| 10 | +module jf_test_40_mod |
| 11 | + |
| 12 | + use json_module, CK => json_CK, CDK => json_CDK, RK => json_RK |
| 13 | + use, intrinsic :: iso_fortran_env , only: error_unit, output_unit |
| 14 | + |
| 15 | + implicit none |
| 16 | + |
| 17 | + private |
| 18 | + public :: test_40 |
| 19 | + |
| 20 | +contains |
| 21 | + |
| 22 | + subroutine test_40(error_cnt) |
| 23 | + |
| 24 | + implicit none |
| 25 | + |
| 26 | + integer,intent(out) :: error_cnt !! report number of errors to caller |
| 27 | + |
| 28 | + type(json_file) :: json |
| 29 | + |
| 30 | + error_cnt = 0 |
| 31 | + |
| 32 | + call json%initialize(stop_on_error=.true., verbose=.true.) |
| 33 | + call json%add('doesnt.existyet', 0.0_rk) |
| 34 | + |
| 35 | + ! the exceptions shoule have been cleared: |
| 36 | + if (json%failed()) then |
| 37 | + call json%print_error_message(error_unit) |
| 38 | + error_cnt = error_cnt + 1 |
| 39 | + end if |
| 40 | + |
| 41 | + call json%print_file() |
| 42 | + call json%destroy() |
| 43 | + |
| 44 | + if (.not. json%failed() .and. error_cnt==0) then |
| 45 | + write(error_unit,'(A)') 'Success!' |
| 46 | + else |
| 47 | + write(error_unit,'(A)') 'Test Failed!' |
| 48 | + end if |
| 49 | + |
| 50 | + end subroutine test_40 |
| 51 | + |
| 52 | +end module jf_test_40_mod |
| 53 | +!***************************************************************************************** |
| 54 | + |
| 55 | +#ifndef INTEGRATED_TESTS |
| 56 | +!***************************************************************************************** |
| 57 | +program jf_test_40 |
| 58 | + |
| 59 | + !! 40th unit test. |
| 60 | + |
| 61 | + use jf_test_40_mod, only: test_40 |
| 62 | + implicit none |
| 63 | + integer :: n_errors |
| 64 | + call test_40(n_errors) |
| 65 | + if ( n_errors /= 0) stop 1 |
| 66 | + |
| 67 | +end program jf_test_40 |
| 68 | +!***************************************************************************************** |
| 69 | +#endif |
0 commit comments