subroutine test_update(this)
class(ESMF_TestMethod), intent(inout) :: this
type(AccumulatorAction) :: acc
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
integer :: status
type(ESMF_Field) :: import_field, export_field
real(kind=R4), parameter :: invalidate_value = 4.0_R4
real(kind=R4) :: update_value
logical :: equals_expected_value
call initialize_objects(importState, exportState, clock, ESMF_TYPEKIND_R4, _RC)
call acc%initialize(importState, exportState, clock, _RC)
call get_field(importState, import_field, _RC)
call FieldSet(import_field, invalidate_value, _RC)
call acc%invalidate(importState, exportState, clock, _RC)
call acc%update(importState, exportState, clock, _RC)
update_value = invalidate_value
@assertTrue(acc%update_calculated, 'update_calculated .FALSE.')
equals_expected_value = FieldIsConstant(acc%accumulation_field, acc%CLEAR_VALUE_R4, _RC)
@assertTrue(equals_expected_value, 'accumulation_field was not cleared.')
equals_expected_value = FieldIsConstant(acc%result_field, update_value, _RC)
@assertTrue(equals_expected_value, 'result_field not equal to update_value')
call get_field(exportState, export_field, _RC)
equals_expected_value = FieldIsConstant(export_field, update_value, _RC)
@assertTrue(equals_expected_value, 'export_field not equal to update_value')
call acc%invalidate(importState, exportState, clock, _RC)
call acc%invalidate(importState, exportState, clock, _RC)
call acc%update(importState, exportState, clock, _RC)
update_value = 2 * invalidate_value
@assertTrue(acc%update_calculated, 'update_calculated .FALSE')
equals_expected_value = FieldIsConstant(acc%accumulation_field, acc%CLEAR_VALUE_R4, _RC)
@assertTrue(equals_expected_value, 'accumulation_field was not cleared.')
equals_expected_value = FieldIsConstant(acc%result_field, update_value, _RC)
@assertTrue(equals_expected_value, 'result_field not equal to update_value.')
call get_field(exportState, export_field, _RC)
equals_expected_value = FieldIsConstant(export_field, update_value, _RC)
@assertTrue(equals_expected_value, 'export_field not equal to update_value')
call destroy_objects(importState, exportState, clock, _RC)
end subroutine test_update