3 use fruit,
only : assert_equals, add_fail, assert_true, assert_false, set_unit_name
25 class(*),
pointer :: data
28 call set_unit_name(
'test_register')
31 descriptor%version=100-i
32 descriptor%name=
"Test "//
str(i)
37 call assert_equals(10,
c_size(component_info),
"Number of registered components after registrations")
40 call assert_equals(
"Test "//
str(i),
c_key_at(component_info, i))
41 data => c_value_at(component_info, i)
44 call assert_equals(real(100-i),
data,
"Version number of component at i correct")
46 call add_fail(
"Unknown type")
60 descriptor%version=100-i
61 descriptor%name=
"Test "//
str(i)
66 call assert_equals(10,
c_size(component_info),
"Number of registered components after registrations")
71 call assert_equals(10-i,
c_size(component_info),
"Component at i has de-registered")
81 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks,&
82 finalisation_callbacks, i
86 modeldump_callbacks, finalisation_callbacks)
91 call assert_true(
associated(data),
"Testing there is some component information if less than 100")
92 call assert_equals(
"Test "//
str(i), data%name,
"Compare registered and expected name")
93 call assert_equals(real(100-i), data%version,
"Compare registered and expected version")
95 call assert_equals(merge(.true., .false., i .le. init_callbacks),
associated(data%initialisation), &
96 "Consistency of initialisation call-back")
97 call assert_equals(merge(.true., .false., i .le. timestep_callbacks),
associated(data%timestep), &
98 "Consistency of timestep call-back")
99 call assert_equals(merge(.true., .false., i .le. consolidation_callbacks),
associated(data%consolidation), &
100 "Consistency of consolidation call-back")
101 call assert_equals(merge(.true., .false., i .le. modeldump_callbacks),
associated(data%modeldump), &
102 "Consistency of model dump call-back")
103 call assert_equals(merge(.true., .false., i .le. finalisation_callbacks),
associated(data%finalisation), &
104 "Consistency of finalisation all-back")
106 call assert_false(
associated(data),
"No component if greater than 100")
117 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks,&
118 finalisation_callbacks, i
123 modeldump_callbacks, finalisation_callbacks)
140 call execute_consolidation_callbacks(testing_state)
141 call execute_modeldump_callbacks(testing_state)
145 call assert_equals(init_callbacks,
init_calls,
"Number of initialisation call-backs post removal")
146 call assert_equals(timestep_callbacks,
timestep_calls,
"Number of timestep call-backs post removal")
147 call assert_equals(consolidation_callbacks,
consolidation_calls,
"Number of consolidation call-backs post removal")
148 call assert_equals(modeldump_callbacks,
modeldump_calls,
"Number of model dump call-backs post removal")
149 call assert_equals(finalisation_callbacks,
finalisation_calls,
"Number of finalisation call-backs post removal")
157 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks, finalisation_callbacks
162 modeldump_callbacks, finalisation_callbacks)
167 call execute_consolidation_callbacks(testing_state)
168 call execute_modeldump_callbacks(testing_state)
172 call assert_equals(init_callbacks,
init_calls,
"Number of initialisation call-backs")
173 call assert_equals(timestep_callbacks,
timestep_calls,
"Number of timestep call-backs")
174 call assert_equals(consolidation_callbacks,
consolidation_calls,
"Number of consolidation call-backs")
175 call assert_equals(modeldump_callbacks,
modeldump_calls,
"Number of model dump call-backs")
176 call assert_equals(finalisation_callbacks,
finalisation_calls,
"Number of finalisation call-backs")
183 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks, finalisation_callbacks
188 modeldump_callbacks, finalisation_callbacks)
191 modeldump_callbacks, finalisation_callbacks)
196 call execute_consolidation_callbacks(testing_state)
197 call execute_modeldump_callbacks(testing_state)
201 call assert_equals(init_callbacks,
init_calls,
"Number of initialisation call-backs post replacement")
202 call assert_equals(timestep_callbacks,
timestep_calls,
"Number of timestep call-backs post replacement")
203 call assert_equals(consolidation_callbacks,
consolidation_calls,
"Number of consolidation call-backs post replacement")
204 call assert_equals(modeldump_callbacks,
modeldump_calls,
"Number of model dump call-backs post replacement")
205 call assert_equals(finalisation_callbacks,
finalisation_calls,
"Number of finalisation call-backs post replacement")
211 integer,
intent(in) :: orig_value, a, b
213 if (orig_value .ge. a)
then
223 modelDump_callbacks, finalisation_callbacks)
225 integer,
intent(out) :: init_callbacks, timestep_callbacks, consolidation_callbacks, &
226 modelDump_callbacks, finalisation_callbacks
231 call random_number(r)
232 init_callbacks = int(r*99)+1
233 call random_number(r)
234 timestep_callbacks = int(r*99)+1
235 call random_number(r)
236 consolidation_callbacks = int(r*99)+1
237 call random_number(r)
238 modeldump_callbacks = int(r*99)+1
239 call random_number(r)
240 finalisation_callbacks = int(r*99)+1
243 modeldump_callbacks, finalisation_callbacks)
248 modelDump_callbacks, finalisation_callbacks)
250 integer,
intent(in) :: init_callbacks, timestep_callbacks, consolidation_callbacks, &
251 modelDump_callbacks, finalisation_callbacks
257 descriptor%name=
"Test "//
str(i)
258 descriptor%version=100-i
304 character(len=15) function str(k)
305 integer,
intent(in) :: k
312 integer :: i, n, clock
313 integer,
dimension(:),
allocatable :: seed
315 call random_seed(
size = n)
318 call system_clock(count=clock)
320 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
321 call random_seed(put = seed)
339 use fruit,
only : init_fruit, run_test_case, fruit_summary