From 5a7a76ac3d7b5d18000886897b97f50b4ee641ee Mon Sep 17 00:00:00 2001 From: Martin Beseda <martinbeseda@seznam.cz> Date: Sun, 19 Nov 2017 23:04:00 +0100 Subject: [PATCH] ENH: Improved unit tests for the module 'connection_m'. --- src/connection_test.f08 | 73 +++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/src/connection_test.f08 b/src/connection_test.f08 index 3fc77cd8..16883f5f 100644 --- a/src/connection_test.f08 +++ b/src/connection_test.f08 @@ -1,4 +1,4 @@ -program a +program connection_test use connection_m use neuron_dummy_m @@ -11,23 +11,76 @@ program a type(interval_connection_t), pointer :: con - n1 = neuron_t(21) - n2 = neuron_t(13) + print *, '+---------------------------------------------+' + print *, '| STARTING TESTING OF THE MODULE CONNECTION_M |' + print *, '+---------------------------------------------+' + print *, 'Creating instances of the class neuron_t...' + n1 = neuron_t(21.3) + n2 = neuron_t(13.7) + print *, 'neuron_t instances were created successfully.' + + print *, 'Assigning instances to pointer...' n1_p => n1 n2_p => n2 + print *, 'Assignment was successful.' + + print *, 'Creating an instance of the class interval_connection_t...' + con => interval_connection_t(n1_p, n2_p, 5.25) + print *, 'The instance of the class interval_connection_t was created successfully.' - con => interval_connection_t(n1_p, n2_p, 5.0) + print *, 'Testing get_weight() method...' + if(con%get_weight() == 5.25) then + print *, 'Test of get_weight() was successfull.' + else + print *, 'ERROR testing method get_weight()!' + stop -1 + end if - print *, 'weight: ', con%get_weight() + print *, 'Testing adjust_weight() method...' + call con%adjust_weight(1.0) + if(con%get_weight() == 6.25) then + print *, 'Test of adjust_weight() was successful.' + else + print *, 'ERROR testing method adjust_weight()!' + stop -1 + end if + print *, 'Assigning input neuron to a pointer using get_input_neuron()...' dummy_p => con%get_input_neuron() - print *, dummy_p%get_state() + print *, 'Assignment was successful.' + + print *, 'Testing method get_state() on the input neuron...' + if(dummy_p%get_state() == 21.3) then + print *, 'Test was successful.' + else + print *, 'ERROR using method get_state() on the input neuron!' + stop -1 + end if + + print *, 'Assigning output neuron to a pointer using get_output_neuron()...' dummy_p => con%get_output_neuron() - print *, dummy_p%get_state() + print *, 'Assignment was successful.' - call con%pass_signal() + print *, 'Testing method get_state() on the output neuron...' + if(dummy_p%get_state() == 13.7) then + print *, 'Test was successful.' + else + print *, 'ERROR using method get_state() on the output neuron!' + stop -1 + end if - print *, dummy_p%get_state() + print *, 'Assigning the value input*weight to the output neuron using method pass_signal()...' + call con%pass_signal() + print *, 'Retrieving state of the output neuron and testing the value...' + if(dummy_p%get_state() == 133.125) then + print *, 'Test was successful.' + else + print *, 'ERROR using method pass_signal()!' + stop -1 + end if -end program a + print *, '+-------------------------------------------------------------+' + print *, '| ALL TESTS OF THE MODULE CONNECTION_M WERE RUN SUCCESSFULLY. |' + print *, '+-------------------------------------------------------------+' +end program connection_test -- GitLab