OpenCMISS-Iron Internal API Documentation
test_framework_routines.f90
Go to the documentation of this file.
1 
43 
46 
47  USE constants
49  USE kinds
50  USE matrix_vector
51  USE strings
52 
53 #include "macros.h"
54 #include "dllexport.h"
55 
56  IMPLICIT NONE
57 
58  PRIVATE
59 
60  !Module parameters
61 
62  !Module types
63 
64  !Module variables
65 
66  !Interfaces
67 
69  MODULE PROCEDURE test_framework_assert_equals_intg
70  MODULE PROCEDURE test_framework_assert_equals_dp
71  MODULE PROCEDURE test_framework_assert_equals_dp1
72  MODULE PROCEDURE test_framework_assert_equals_dp2
73  END INTERFACE !TEST_FRAMEWORK_ASSERT_EQUALS
74 
76 
77 CONTAINS
78 
79  !
80  !================================================================================================================================
81  !
82 
84  SUBROUTINE test_framework_assert_equals_intg(EXPECTED_VALUE,ACTUAL_VALUE,ERR)
85  !DLLEXPORT(TEST_FRAMEWORK_ASSERT_EQUALS_INTG)
86 
87  !Argument variables
88  INTEGER(INTG), INTENT(IN) :: EXPECTED_VALUE
89  INTEGER(INTG), INTENT(IN) :: ACTUAL_VALUE
90  INTEGER(INTG), INTENT(OUT) :: ERR
91  TYPE(varying_string) :: ERROR
92  !Local Variables
93 
94  enters("TEST_FRAMEWORK_ASSERT_EQUALS_INTG",err,error,*999)
95 
96  IF(expected_value/=actual_value) THEN
97  CALL flagerror("Not equal",err,error,*999)
98  ENDIF
99 
100  exits("TEST_FRAMEWORK_ASSERT_EQUALS_INTG")
101  RETURN
102 999 errorsexits("TEST_FRAMEWORK_ASSERT_EQUALS_INTG",err,error)
103  RETURN
104  END SUBROUTINE test_framework_assert_equals_intg
105 
106  !
107  !================================================================================================================================
108  !
109 
111  SUBROUTINE test_framework_assert_equals_dp1(EXPECTED_VALUE,ACTUAL_VALUE,ERR)
112  !DLLEXPORT(TEST_FRAMEWORK_ASSERT_EQUALS_DP1)
113  !Argument variables
114  REAL(DP), INTENT(IN) :: EXPECTED_VALUE
115  REAL(DP), INTENT(IN) :: ACTUAL_VALUE
116  INTEGER(INTG), INTENT(OUT) :: ERR
117  TYPE(varying_string) :: ERROR
118  !Local Variables
119 
120  enters("TEST_FRAMEWORK_ASSERT_EQUALS_DP1",err,error,*999)
121 
122  CALL test_framework_assert_equals_dp2(expected_value,actual_value,zero_tolerance,err)
123 
124  exits("TEST_FRAMEWORK_ASSERT_EQUALS_DP1")
125  RETURN
126 999 errorsexits("TEST_FRAMEWORK_ASSERT_EQUALS_DP1",err,error)
127  RETURN
128  END SUBROUTINE test_framework_assert_equals_dp1
129 
130  !
131  !================================================================================================================================
132  !
133 
135  SUBROUTINE test_framework_assert_equals_dp2(EXPECTED_VALUE,ACTUAL_VALUE,TOLERANCE,ERR)
136  !DLLEXPORT(TEST_FRAMEWORK_ASSERT_EQUALS_DP2)
137 
138  !Argument variables
139  REAL(DP), INTENT(IN) :: EXPECTED_VALUE
140  REAL(DP), INTENT(IN) :: ACTUAL_VALUE
141  REAL(DP), INTENT(IN) :: TOLERANCE
142  INTEGER(INTG), INTENT(OUT) :: ERR
143  TYPE(varying_string) :: ERROR
144  !Local Variables
145 
146  enters("TEST_FRAMEWORK_ASSERT_EQUALS_DP2",err,error,*999)
147 
148  IF(abs(expected_value-actual_value)>tolerance) THEN
149  CALL flagerror("Not Equal",err,error,*999)
150  ENDIF
151 
152  exits("TEST_FRAMEWORK_ASSERT_EQUALS_DP2")
153  RETURN
154 999 errorsexits("TEST_FRAMEWORK_ASSERT_EQUALS_DP1",err,error)
155  RETURN
156  END SUBROUTINE test_framework_assert_equals_dp2
157 
158  !
159  !================================================================================================================================
160  !
161 
163  SUBROUTINE test_framework_assert_equals_dp(EXPECTED_VALUE,ACTUAL_VALUE,ERR)
164  !DLLEXPORT(TEST_FRAMEWORK_ASSERT_EQUALS_DP)
165  !Argument variables
166  REAL(DP), INTENT(IN) :: EXPECTED_VALUE(:)
167  REAL(DP), INTENT(IN) :: ACTUAL_VALUE(:)
168  INTEGER(INTG), INTENT(OUT) :: ERR
169  TYPE(varying_string) :: ERROR
170  !Local Variables
171  INTEGER(INTG) :: i
172 
173  enters("TEST_FRAMEWORK_ASSERT_EQUALS_DP",err,error,*999)
174 
175  IF(SIZE(expected_value)==SIZE(actual_value)) THEN
176  DO i=1,SIZE(expected_value)
177  CALL test_framework_assert_equals(expected_value(i),actual_value(i),err)
178  ENDDO !i
179  ELSE
180  CALL flagerror("Not Equal",err,error,*999)
181  ENDIF
182 
183  exits("TEST_FRAMEWORK_ASSERT_EQUALS_DP")
184  RETURN
185 999 errorsexits("TEST_FRAMEWORK_ASSERT_EQUALS_DP",err,error)
186  RETURN
187  END SUBROUTINE test_framework_assert_equals_dp
188 
189  !
190  !================================================================================================================================
191  !
192 
194  SUBROUTINE test_framework_gradient_value_get(X_VALUES,Y_VALUES,GRADIENT_VALUE)
195  !DLLEXPORT(TEST_FRAMEWORK_GRADIENT_VALUE_GET)
196 
197  !Argument variables
198  REAL(DP), INTENT(IN) :: X_VALUES(:)
199  REAL(DP), INTENT(IN) :: Y_VALUES(:)
200  REAL(DP), INTENT(OUT) :: GRADIENT_VALUE
201  INTEGER(INTG) :: ERR
202  TYPE(varying_string) :: ERROR
203  !Local Variables
204  INTEGER(INTG) :: i, interval_size
205 
206  enters("TEST_FRAMEWORK_GRADIENT_VALUE_GET",err,error,*999)
207 
208  IF(SIZE(x_values)==SIZE(y_values)) THEN
209  gradient_value=0.0_dp
210  interval_size=SIZE(x_values)-1
211  DO i=1,SIZE(x_values)
212  IF(i/=1) THEN
213  gradient_value=gradient_value+(y_values(i)-y_values(i-1))/(x_values(i)-x_values(i-1))/interval_size
214  ENDIF
215  ENDDO !i
216  ELSE
217  CALL flagerror('Size of x and Size of y do not match',err,error,*999)
218  ENDIF
219 
220  exits("TEST_FRAMEWORK_GRADIENT_VALUE_GET")
221  RETURN
222 999 errorsexits("TEST_FRAMEWORK_GRADIENT_VALUE_GET",err,error)
223  RETURN
224  END SUBROUTINE test_framework_gradient_value_get
225 
226 END MODULE test_framework_routines
subroutine test_framework_assert_equals_dp1(EXPECTED_VALUE, ACTUAL_VALUE, ERR)
Check if the actual real(DP) value is as expected.
This module contains all string manipulation and transformation routines.
Definition: strings.f90:45
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
This module contains all program wide constants.
Definition: constants.f90:45
subroutine, public test_framework_gradient_value_get(X_VALUES, Y_VALUES, GRADIENT_VALUE)
Get the gradient value of two array.
subroutine test_framework_assert_equals_dp(EXPECTED_VALUE, ACTUAL_VALUE, ERR)
Check if the actual real(DP) values is as expected.
This module contains all routines dealing with (non-distributed) matrix and vectors types...
This module handles test framework routines.
subroutine test_framework_assert_equals_intg(EXPECTED_VALUE, ACTUAL_VALUE, ERR)
Check if the actual integer value is as expected.
subroutine test_framework_assert_equals_dp2(EXPECTED_VALUE, ACTUAL_VALUE, TOLERANCE, ERR)
Check if the actual real(DP) value is as expected.
real(dp), parameter zero_tolerance
Definition: constants.f90:70
This module contains all kind definitions.
Definition: kinds.f90:45