YAC 3.13.0
Yet Another Coupler
Loading...
Searching...
No Matches
utest.F90
Go to the documentation of this file.
1! Copyright (c) 2024 The YAC Authors
2!
3! SPDX-License-Identifier: BSD-3-Clause
4
5module utest
6
7 implicit none
8
9 private
10
13
14 integer :: utest_testcount, utest_errorcount
15 real :: start, end
16
17contains
18
19 subroutine start_test (name)
20 character(len=*), intent(in) :: name
21 utest_errorcount = 0
22 utest_testcount = 0
23 print *, "testing ", name, ":"
24 end subroutine start_test
25
26 subroutine stop_test ()
27 if (utest_errorcount == 0) then
28 print *, "all",utest_testcount, "test(s) succeeded"
29 else
30 write(0,*) utest_errorcount, " out of ", &
31 utest_testcount, " test(s) failed"
32 endif
33 end subroutine stop_test
34
35 subroutine start_timer (name)
36 character(len=*), intent(in) :: name
37 call cpu_time(start)
38 print *, "start timing ", name
39 end subroutine start_timer
40
41 subroutine stop_timer ()
42 call cpu_time(end)
43 print '(" elapsed time:",f6.3," seconds.")',end-start
44 end subroutine stop_timer
45
46 subroutine test_v_r(arg, file, line)
47
48 logical, intent(in) :: arg
49 integer, intent(in) :: line
50 character(len=*), intent(in) :: file
51
52 utest_testcount = utest_testcount + 1
53 if (arg) then
54 print *, "- test", utest_testcount, "succeeded"
55 return
56 else
57 utest_errorcount = utest_errorcount + 1
58 write(0,*) "- test", utest_testcount, "failed (",file," :", line, ")"
59 endif
60
61 end subroutine test_v_r
62
63 subroutine test_r(arg, file, line)
64
65 logical, intent(in) :: arg
66 integer, intent(in) :: line
67 character(len=*), intent(in) :: file
68
69 utest_testcount = utest_testcount + 1
70 if (arg) then
71 print *, "- test", utest_testcount, "succeeded"
72 return
73 else
74 utest_errorcount = utest_errorcount + 1
75 write(0,*) "- test", utest_testcount, "failed (",file," :", line, ")"
76 endif
77
78 end subroutine test_r
79
80 subroutine exit_tests()
81
82 if (utest_errorcount > 0) then
83 stop 1
84 endif
85 end subroutine exit_tests
86
87end module utest
Definition utest.F90:5
subroutine, public start_test(name)
Definition utest.F90:20
subroutine, public stop_test()
Definition utest.F90:27
subroutine, public stop_timer()
Definition utest.F90:42
subroutine, public exit_tests()
Definition utest.F90:81
subroutine, public test_r(arg, file, line)
Definition utest.F90:64
subroutine, public start_timer(name)
Definition utest.F90:36
subroutine, public test_v_r(arg, file, line)
Definition utest.F90:47