Newer
Older
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/Connection.h"
#include "../NetConnection/ConnectionWeight.h"
#include "../Neuron/NeuronLinear.h"
#include <iostream>
/**
* Boost testing suite for testing Connection.h
*/
BOOST_AUTO_TEST_SUITE(Connection_test)
/**
* Test of constructor of Connection
*/
BOOST_AUTO_TEST_CASE(Connection_construction__test) {
Neuron *neuron1 = new NeuronLinear(2, 3);
Neuron *neuron2 = new NeuronLinear(4, 5);
std::vector<double> w_array = {2, 3, 4, 5, 6};
ConnectionWeight *conn = new ConnectionWeight(2, &w_array);
BOOST_CHECK_EQUAL(neuron1, connection.get_neuron_in());
BOOST_CHECK_EQUAL(neuron2, connection.get_neuron_out());
}
/**
* Test of pass_signal method
*/
BOOST_AUTO_TEST_CASE(Connection_pass_signal_test) {
Neuron *neuron1 = new NeuronLinear(2, 3);
Neuron *neuron2 = new NeuronLinear(4, 5);
std::vector<double> w_array = {2, 3, 4, 5, 6};
std::function<double(double *, int *, int)> f = [](double *weight_array, int *index_array, int n_params) {
double a = weight_array[0];
double b = weight_array[1];
return (a + 1.5 * b);
};
ConnectionWeight *conn = new ConnectionWeight(2, &w_array);
Connection connection(neuron1, neuron2, conn);
neuron1->activate();
neuron2->activate();
// test of neuron state before passing signal
BOOST_CHECK_EQUAL(4, neuron2->get_state());
connection.pass_signal();
neuron2->activate();
// test of neuron state after passing signal