Commit 3b5fbcef authored by Martin Beseda's avatar Martin Beseda

DEL: connection_m.fun moved to fortran2008 folder

parent 63d8b367
!> Unit test suite for connections (synapses)
!! in neural networks.
!!
!! @author Martin Beseda
!! @author Martin Mrovec
!! @date 2017
test_suite connection_m
! Global variables declaration
class(neuron_t), pointer :: n1_p
class(neuron_t), pointer :: n2_p
class(neuron_t), pointer :: dummy_p
type(connection_t), pointer :: con
!------------------------!---------------------------------------------------------------
! Setup before each test !
!------------------------!
setup
write(*,*) '+------------------------+'
write(*,*) '| SETUP BEFORE UNIT TEST |'
write(*,*) '+------------------------+'
write(*,*) 'Creating instances of the class mock_neuron_t...'
n1_p => mock_neuron_t()
n2_p => mock_neuron_t()
write(*,*) 'Creating an instance of the class interval_connection_t...'
con => connection_t(n1_p, n2_p, real(5.25, real_4neuro))
nullify(dummy_p)
write(*,*) 'Ready for test.'
end setup
!-------------------------!--------------------------------------------------------------
! Cleanup after each test !
!-------------------------!
teardown
write(*,*) '+-------------------------+'
write(*,*) '| CLEANUP AFTER UNIT TEST |'
write(*,*) '+-------------------------+'
write(*,*) 'Deallocating everything.'
deallocate(con)
nullify(dummy_p)
write(*,*) 'Cleaned succesfully.'
end teardown
!-------!--------------------------------------------------------------------------------
! Tests !
!-------!
!-----------------------------!
! Test of getters and setters !
!-----------------------------!
test getters_setters
write(*,*) '+++ Test of getters and setters ...'
! Test of get_weight
assert_real_equal(con%get_weight(), 5.25e+0)
! Test of adjust_weight
call con%adjust_weight(real(1.0, real_4neuro))
assert_real_equal(con%get_weight(), 6.25e+0)
write(*,*) '... finished +++'
end test
!----------------------------------!
! Test of input and output neurons !
!----------------------------------!
test input_and_output_neurons
write(*,*) '+++ Test of input and output neurons ...'
! Input neuron
dummy_p => con%get_input_neuron()
assert_real_equal(dummy_p%get_state(),15.0e+0)
! Output neuron
dummy_p => con%get_output_neuron()
assert_real_equal(dummy_p%get_state(),15.0e+0)
write(*,*) '... finished +++'
end test
!--------------------------!
! Test of passing a signal !
!--------------------------!
test pass_signal
write(*,*) '+++ Test of passing a signal ...'
dummy_p => con%get_output_neuron()
call con%pass_signal()
assert_real_equal(dummy_p%get_potential(), 78.75e+0)
write(*,*) '... finished +++'
end test
end test_suite
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment