Line data Source code
1 : ! This file is part of fortran_tester
2 : ! Copyright 2015 Pierre de Buyl
3 : ! License: BSD
4 :
5 1 : program test_tester_1
6 1 : 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 1 : call test% init()
15 :
16 1 : call test% assert_equal(-121, -11**2)
17 :
18 1 : 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 1 : 0.8541147722227219d0, 0.267520651034313d0 , 0.6948550035165076d0])
24 :
25 1 : call test% assert_close(0.d0, sin(pi))
26 :
27 1 : call test% assert_equal(0.d0, 0*1.d0)
28 :
29 1 : call test% assert_equal(.true., 2 > 1)
30 :
31 1 : 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 1 : 9.0014871205366358])
38 :
39 1 : call test% assert_close(1.d0, (1.d0+1.d-16))
40 :
41 1 : 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 1 : 0.57437861, 0.4879709 , 0.00986957-epsilon(1.0)])
47 :
48 1 : call test% assert_close([1.d0, 2.d0], [1.d0, 2.d0])
49 :
50 1 : call test% assert_positive(epsilon(1.))
51 1 : call test% assert_positive(0.1)
52 1 : call test% assert_positive(0.1d0)
53 :
54 1 : call test% assert_positive([1., 2., 0.])
55 1 : call test% assert_positive([1.d0, huge(1.d0)])
56 :
57 1 : call test% assert_equal(1, 1)
58 1 : call test% assert_equal(1_long_k, 1_long_k)
59 1 : 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 : [1_long_k, -huge(1_long_k), huge(1_long_k), 0_long_k])
62 :
63 1 : call test% assert_positive(2**30)
64 1 : call test% assert_positive(2_long_k**62)
65 1 : call test% assert_positive([2**30, 1, 0])
66 1 : call test% assert_positive([2_long_k**62, 1_long_k, 0_long_k])
67 :
68 1 : call test% print()
69 :
70 1 : end program test_tester_1
|