From be2d88a2da11c548cd1d252bceb8b46f596f031c Mon Sep 17 00:00:00 2001
From: mrovma <martin.mrovec@vsb.cz>
Date: Thu, 7 Dec 2017 18:55:54 +0100
Subject: [PATCH] FIX: test suite for connection

---
 src/connection_m.fun | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/connection_m.fun b/src/connection_m.fun
index 33c70b6f..ada65481 100644
--- a/src/connection_m.fun
+++ b/src/connection_m.fun
@@ -7,13 +7,11 @@
 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
+class(neuron_t), pointer :: n1_p
+class(neuron_t), pointer :: n2_p
 
-type(neuron_t), pointer :: dummy_p
+class(neuron_t), pointer :: dummy_p
 
 type(connection_t), pointer :: con
 
@@ -24,14 +22,11 @@ setup
   write(*,*) '+------------------------+'
   write(*,*) '| SETUP BEFORE UNIT TEST |'
   write(*,*) '+------------------------+'
-  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
+  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, 5.25)
+  con => connection_t(n1_p, n2_p, real(5.25, real_4neuro))
   nullify(dummy_p)
   write(*,*) 'Ready for test.'
 end setup
@@ -62,7 +57,7 @@ test getters_setters
   ! Test of get_weight
   assert_real_equal(con%get_weight(), 5.25e+0)
   ! Test of adjust_weight
-  call con%adjust_weight(1.0)
+  call con%adjust_weight(real(1.0, real_4neuro))
   assert_real_equal(con%get_weight(), 6.25e+0)
   write(*,*) '... finished +++'
 end test
@@ -74,10 +69,10 @@ 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)
+  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(),13.7d+0)
+  assert_real_equal(dummy_p%get_state(),15.0e+0)
   write(*,*) '... finished +++'
 end test
 
@@ -88,7 +83,7 @@ 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_state(), 111.825d+0)
+   assert_real_equal(dummy_p%get_potential(), 78.75e+0)
    write(*,*) '... finished +++'
 end test
 
-- 
GitLab