Line data Source code
1 : ! This file is part of fortran_tester
2 : ! Copyright 2015 2018 Pierre de Buyl
3 : ! License: BSD
4 :
5 1 : program test_tester_1
6 1 : use tester
7 : implicit none
8 :
9 : integer, parameter :: rk = selected_real_kind(15)
10 : complex(kind=rk) :: x, y
11 : complex(kind=rk) :: a(5), b(5)
12 : complex :: c(3), d(3)
13 : type(tester_t) :: test
14 :
15 1 : call test% init()
16 :
17 1 : call test% assert_equal((1234, -1234), (1234, -1234))
18 :
19 1 : call test% assert_close((1._rk, 0._rk), (1._rk, 0._rk))
20 :
21 1 : call test% assert_close(cmplx(1., epsilon(0.)), (1., 0.))
22 :
23 1 : x = (0._rk, 1._rk)
24 1 : y = cmplx(epsilon(0._rk), 1._rk, kind=rk)
25 1 : call test% assert_close(x, y)
26 :
27 1 : x = cmplx(-1158.1181871905803291, 779.0494065373754893)
28 1 : y = cmplx(-1158.1181871905803291, 779.0494065373754893)
29 :
30 1 : call test% assert_equal(x, y)
31 :
32 1 : c = 1
33 1 : d = 1
34 1 : d = d + cmplx(0, epsilon(0.))
35 :
36 1 : call test% assert_close(c, d)
37 :
38 1 : c = cmplx(1154274.4026509234681726, -461087.8365501734078862)
39 1 : d = cmplx(1154274.4026509234681726, -461087.8365501734078862)
40 :
41 1 : call test% assert_equal(c, d)
42 :
43 1 : a = -10
44 1 : b = -10
45 :
46 1 : call test% assert_equal(a, b)
47 :
48 1 : a = 0
49 1 : b = epsilon(0._rk)
50 :
51 1 : call test% assert_close(a, b)
52 :
53 1 : b(1) = b(1) + cmplx(0._rk, epsilon(real(b(1))), kind=rk)
54 :
55 1 : call test% assert_close(a, b)
56 :
57 1 : call test% print()
58 :
59 1 : end program test_tester_1
|