fortran_tester
 All Classes Files Functions Variables Pages
test_tester_01.f90
Go to the documentation of this file.
1 ! This file is part of fortran_tester
2 ! Copyright 2015 Pierre de Buyl
3 ! License: BSD
4 
5 program test_tester_1
6  use tester
7  implicit none
8 
9  integer, parameter :: long_k = selected_int_kind(18)
10  double precision :: pi = 4*atan(1.d0)
11 
12  type(tester_t) :: test
13 
14  call test% init()
15 
16  call test% assert_equal(-121, -11**2)
17 
18  call test% assert_equal([1, -10, 1899010], [1, -10, 1899010])
19 
20  call test% assert_equal([0.2420243742417814d0, 0.4924788296716989d0, &
21  0.8541147722227219d0, 0.267520651034313d0 , 0.6948550035165076d0], &
22  [0.2420243742417814d0, 0.4924788296716989d0, &
23  0.8541147722227219d0, 0.267520651034313d0 , 0.6948550035165076d0])
24 
25  call test% assert_close(0.d0, sin(pi))
26 
27  call test% assert_equal(0.d0, 0*1.d0)
28 
29  call test% assert_equal(.true., 2 > 1)
30 
31  call test% assert_equal(1.0, 1.0)
32 
33  call test% assert_equal( &
34  [7.2936402920067644, 3.0975232096437191, 9.2077205929200456, &
35  9.0014871205366358], &
36  [7.2936402920067644, 3.0975232096437191, 9.2077205929200456, &
37  9.0014871205366358])
38 
39  call test% assert_close(1.d0, (1.d0+1.d-16))
40 
41  call test% assert_close(1., (1.+1.e-7))
42 
43  call test% assert_close([ 0.58557761, 0.04035789, 0.30463428, &
44  0.57437861, 0.4879709 , 0.00986957], &
45  [ 0.58557761+epsilon(1.0), 0.04035789, 0.30463428+2*epsilon(1.0), &
46  0.57437861, 0.4879709 , 0.00986957-epsilon(1.0)])
47 
48  call test% assert_close([1.d0, 2.d0], [1.d0, 2.d0])
49 
50  call test% assert_positive(epsilon(1.))
51  call test% assert_positive(0.1)
52  call test% assert_positive(0.1d0)
53 
54  call test% assert_positive([1., 2., 0.])
55  call test% assert_positive([1.d0, huge(1.d0)])
56 
57  call test% assert_equal(1, 1)
58  call test% assert_equal(1_long_k, 1_long_k)
59  call test% assert_equal([1, -huge(1), huge(1), 0], [1, -huge(1), huge(1), 0])
60  call test% assert_equal([1_long_k, -huge(1_long_k), huge(1_long_k), 0_long_k], &
61  [1_long_k, -huge(1_long_k), huge(1_long_k), 0_long_k])
62 
63  call test% assert_positive(2**30)
64  call test% assert_positive(2_long_k**62)
65  call test% assert_positive([2**30, 1, 0])
66  call test% assert_positive([2_long_k**62, 1_long_k, 0_long_k])
67 
68  call test% print()
69 
70 end program test_tester_1
program test_tester_1
Routines to test Fortran programs.
Definition: tester.f90:11
The main tester class.
Definition: tester.f90:19