Commit fc37cd88 authored by Martin Mrovec's avatar Martin Mrovec

ENH: Added funit tests for connection_m

parent 68690ce9
This diff is collapsed.
......@@ -6,7 +6,7 @@ enable_language(Fortran)
# Default installation location #
#-------------------------------#
# Linux: /usr/local
# Windows: c:/Program Files
# Windows: C:/Users/Marti/OneDrive/Dokumenty/Fortran/git4Neuro/4NeuroMrovma/4Neuro/t
#------------#
# Build type #
......
......@@ -3,3 +3,4 @@
cd build;
./connection_test.out
funit connection_m
test_suite connection_m
! Global variables declaration
type(neuron_t), target :: n1
type(neuron_t), target :: n2
type(neuron_t), pointer :: n1_p
type(neuron_t), pointer :: n2_p
type(neuron_t), pointer :: dummy_p
type(interval_connection_t), pointer :: con
! Setup before each test
setup
write(*,*) 'Creating instances of the class neuron_t...'
n1 = neuron_t(21.3)
n2 = neuron_t(13.7)
write(*,*) 'Assigning instances to pointer...'
n1_p => n1
n2_p => n2
print *, 'Creating an instance of the class interval_connection_t...'
con => interval_connection_t(n1_p, n2_p, 5.25)
nullify(dummy_p)
end setup
! After each test do the cleanup
teardown
write(*,*) 'Deallocating everything.'
deallocate(con)
deallocate(n1_p)
deallocate(n2_p)
nullify(dummy_p)
end teardown
! 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(1.0)
assert_real_equal(con%get_weight(), 6.25e+0)
end test
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(),21.3d+0)
! Output neuron
dummy_p => con%get_output_neuron()
assert_real_equal(dummy_p%get_state(),13.7d+0)
end test
test pass_signal
write(*,*) 'Test of passing a signal.'
dummy_p => con%get_input_neuron()
call con%pass_signal()
assert_real_equal(dummy_p%get_state(), 111.825d+0)
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