Commit 5fe40bf3 authored by David Vojtek's avatar David Vojtek

FIX: Fixed unit_test to new structure

parent 57948200
......@@ -3,4 +3,5 @@
//
#define BOOST_TEST_MODULE neuron_test
#include <boost/test/included/unit_test.hpp>
#include <boost/test/included/unit_test.hpp>
\ No newline at end of file
##############
# UNIT TESTS #
##############
#add_executable(neuron_test Neuron_test.cpp)
#target_link_libraries(neuron_test boost_unit_test 4neuro)
add_executable(linear_neuron_test NeuronLinear_test.cpp)
target_link_libraries(linear_neuron_test boost_unit_test 4neuro)
add_executable(constant_neuron_test NeuronConstant_test.cpp)
target_link_libraries(constant_neuron_test boost_unit_test 4neuro)
add_executable(binary_neuron_test NeuronBinary_test.cpp)
target_link_libraries(binary_neuron_test boost_unit_test 4neuro)
add_executable(logistic_neuron_test NeuronLogistic_test.cpp)
target_link_libraries(logistic_neuron_test boost_unit_test 4neuro)
add_executable(connectionFunctionGeneral_test ConnectionFunctionGeneral_test.cpp)
target_link_libraries(connectionFunctionGeneral_test boost_unit_test 4neuro)
add_executable(neural_network_test NeuralNetwork_test.cpp)
target_link_libraries(neural_network_test boost_unit_test 4neuro)
add_executable(connection_Function_identity_test ConnectionFunctionIdentity_test.cpp)
target_link_libraries(connection_Function_identity_test boost_unit_test 4neuro)
add_executable(dataset_test DataSet_test.cpp)
target_link_libraries(dataset_test boost_unit_test 4neuro)
add_executable(errorfunction_test ErrorFunctions_test.cpp)
target_link_libraries(errorfunction_test boost_unit_test 4neuro)
add_executable(particle_swarm_test ParticleSwarm_test.cpp)
target_link_libraries(particle_swarm_test boost_unit_test 4neuro)
add_executable(particle_test Particle_test.cpp)
target_link_libraries(particle_test boost_unit_test 4neuro)
add_executable(NeuralNetworkSum_test NeuralNetworkSum_test.cpp)
target_link_libraries(NeuralNetworkSum_test boost_unit_test 4neuro)
add_executable(DESolver_test DESolver_test.cpp)
target_link_libraries(DESolver_test boost_unit_test 4neuro)
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionFunctionGeneral.h"
#include "../Neuron/NeuronLinear.h"
#include <iostream>
/**
* Boost testing suite for testing ConnectionFunctionGeneral.h
*/
BOOST_AUTO_TEST_SUITE(Connection_test)
/**
* Test of constructor of Connection
*/
BOOST_AUTO_TEST_CASE(Connection_construction__test) {
BOOST_CHECK_NO_THROW(ConnectionFunctionGeneral *functionGeneral = new ConnectionFunctionGeneral());
std::vector<size_t> param_indices;
param_indices.push_back(0);
std::string paramToFunction = "this do nothing! Why is it here?";
BOOST_CHECK_NO_THROW(ConnectionFunctionGeneral *functionGeneral = new ConnectionFunctionGeneral(param_indices,
paramToFunction));
}
BOOST_AUTO_TEST_CASE(Connection_eval_test) {
ConnectionFunctionGeneral *functionGeneral = new ConnectionFunctionGeneral();
//TODO implementation not finnish yet;
std::vector<double> parameter_space;
BOOST_CHECK_EQUAL(0, functionGeneral->eval(parameter_space));
}
BOOST_AUTO_TEST_CASE(Connection_eval_partial_derivative_test) {
//TODO function not implemented yet
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -8,7 +8,7 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionWeightIdentity.h"
#include "../NetConnection/ConnectionFunctionIdentity.h"
/**
* Boost testing suite for testing ConnectionWeightIdentity.h
......@@ -16,25 +16,32 @@
BOOST_AUTO_TEST_SUITE(ConnectionWeightIdentity_test)
/**
* Test of correct construction of ConnectionWeightIdentity
* Test of correct construction of ConnectionFunctionIdentity
*/
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_construction_test) {
std::vector<double> weight_array = {1, 2, 3, 4, 5};
//Test of none exception when creation new instance of ConnectionWeightIdentity
BOOST_CHECK_NO_THROW(ConnectionWeightIdentity CWI(&weight_array));
//Test of none exception when creation new instance of ConnectionFunctionIdentity
BOOST_CHECK_NO_THROW(ConnectionFunctionIdentity *CFI = new ConnectionFunctionIdentity() );
BOOST_CHECK_NO_THROW(ConnectionFunctionIdentity *CFI = new ConnectionFunctionIdentity(2) );
}
/**
* Test of eval method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_eval_test) {
std::vector<double> weight_array = {1, 2, 3, 4, 5};
ConnectionWeightIdentity CWI(&weight_array);
int para[5] = {3, 1, 2, 3, 4};
CWI.SetParamIndices(para);
ConnectionFunctionIdentity *CFI1 = new ConnectionFunctionIdentity();
ConnectionFunctionIdentity *CFI2 = new ConnectionFunctionIdentity(0);
ConnectionFunctionIdentity *CFI3 = new ConnectionFunctionIdentity(2);
std::vector<double> parameter_space;
parameter_space.push_back(5);
//Test of correct output of eval method
BOOST_CHECK_EQUAL(4, CWI.eval());
BOOST_CHECK_EQUAL(1, CFI1->eval(parameter_space));
BOOST_CHECK_EQUAL(5, CFI2->eval(parameter_space));
BOOST_CHECK_THROW(CFI3->eval(parameter_space), std::out_of_range);
}
BOOST_AUTO_TEST_SUITE_END()
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionWeight.h"
/**
* Boost testing suite for testing ConnectionWeight.h
*/
BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
/**
* Test of construction of ConnectionWeight
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_construction__test) {
std::vector<double> * w_array = nullptr ;
//Tests of no exception when, create new instance
BOOST_CHECK_NO_THROW( ConnectionWeight conn(2, w_array ));
BOOST_CHECK_NO_THROW( ConnectionWeight conn);
}
/**
* Test of setParamIndices and SetParamIndex methods
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_param_test){
std::vector<double> w_array= {0,1,2,3,4} ;
ConnectionWeight conn(5, &w_array );
ConnectionWeight connbad(7, &w_array);
int para[5]={0,1,2,3,4};
//Test of no exception when call SetParamIndices method on instance created with with correct parameters
BOOST_CHECK_NO_THROW(conn.SetParamIndices(para));
//Test of no exception when call SetParamIndex method on instance created with with correct parameters
BOOST_CHECK_NO_THROW(conn.SetParamIndex(2,2));
// Features not implemented yet
//Test of expected exception out_of_range when call SetParamIndices method on instance created with with incorrect parameters
//BOOST_CHECK_THROW(connbad.SetParamIndices(para), std::out_of_range);
//Test of expected exception out_of_range when call SetParamIndex method on instance created with incorrect parameters
//BOOST_CHECK_THROW(connbad.SetParamIndex(2,8), std::out_of_range);
}
/**
* Test of eval method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_eval__test) {
std::vector<double> w_array= {1,2,3,4,5} ;
ConnectionWeight conn(5, &w_array );
int para[5]={1,2,3,4,5};
conn.SetParamIndices(para);
//Test of correct output after calling eval() method
BOOST_CHECK_EQUAL(120, conn.eval());
}
/**
* Test of adjust_weights method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_weight_adjustment_test) {
std::vector<double> w_array= {1,2,3,4,5} ;
double w_array2[5] = {5,4,3,2,1};
ConnectionWeight conn(5, &w_array);
int para[5]={0,1,2,3,4};
conn.SetParamIndices(para);
conn.adjust_weights(w_array2);
//Test of correct eval output after adjusting weights
BOOST_CHECK_EQUAL(7776, conn.eval());
}
/**
* Test of set_weights method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_weight_set_test) {
std::vector<double> w_array= {2,3,4,5,6} ;
double w_array2[5] = {1,2,3,4,5};
ConnectionWeight conn(5, &w_array );
conn.eval();
int para[5]={0,1,2,3,4};
conn.SetParamIndices(para);
conn.set_weights(w_array2);
//Test of correct eval output after setting new weights
BOOST_CHECK_EQUAL(120, conn.eval());
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
/**
* 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);
Connection connection(neuron1, neuron2, conn);
//Test of correct input neuron
BOOST_CHECK_EQUAL(neuron1, connection.get_neuron_in());
//Test of correct output neuron
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
BOOST_CHECK_EQUAL(7204, neuron2->get_state());
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -91,11 +91,10 @@ BOOST_AUTO_TEST_SUITE(DESolver_test)
* Test of DESolver construction
*/
BOOST_AUTO_TEST_CASE(DESolver_construction_test) {
BOOST_CHECK_THROW(DESolver(0, 1, 1, 1), std::invalid_argument);
BOOST_CHECK_THROW(DESolver(1, 0, 1, 1), std::invalid_argument);
BOOST_CHECK_THROW(DESolver(1, 1, 0, 1), std::invalid_argument);
BOOST_CHECK_THROW(DESolver(1, 1, 1, 0), std::invalid_argument);
BOOST_CHECK_NO_THROW(DESolver deSolver(1, 1, 1, 1));
BOOST_CHECK_THROW(DESolver(0, 1, 1), std::invalid_argument);
BOOST_CHECK_THROW(DESolver(1, 0, 1), std::invalid_argument);
BOOST_CHECK_THROW(DESolver(1, 1, 0), std::invalid_argument);
BOOST_CHECK_NO_THROW(DESolver deSolver(1, 1, 1));
/*boost::test_tools::output_test_stream output;
{
......@@ -110,12 +109,13 @@ BOOST_AUTO_TEST_SUITE(DESolver_test)
* Test of DESolver get_solution method
*/
BOOST_AUTO_TEST_CASE(DESolver_get_solution_test) {
DESolver deSolver(1, 1, 1, 1);
NeuralNetwork *network = deSolver.get_solution();
DESolver deSolver(1, 1, 1);
MultiIndex *alpha = new MultiIndex(1);
NeuralNetwork *network = deSolver.get_solution(*alpha);
BOOST_CHECK_EQUAL(1, network->get_n_inputs());
BOOST_CHECK_EQUAL(1, network->get_n_outputs());
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
BOOST_AUTO_TEST_SUITE_END()
......@@ -9,9 +9,10 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
#include <iostream>
#include <boost/archive/archive_exception.hpp>
#include "../DataSet/DataSet.h"
#include "stdio.h"
#include <iostream>
//#include <boost/filesystem.hpp>
/**
......@@ -37,6 +38,7 @@ BOOST_AUTO_TEST_SUITE(DataSet_test)
BOOST_AUTO_TEST_CASE(DataSet_construction_from_file_test) {
//test of exception with non-existing file path
//TODO resolve exception throw
// DataSet dataSet("file/unknown");
//BOOST_CHECK_THROW(DataSet dataSet("file unknown"), boost::archive::archive_exception::input_stream_error);
}
......@@ -204,7 +206,11 @@ BOOST_AUTO_TEST_SUITE(DataSet_test)
DataSet dataSet(&data_vec);
int elements = dataSet.get_n_elements();
dataSet.store_text("testDataSet");
std::string filename = "testDataSet";
dataSet.store_text(filename);
//Test of correct file creations
//BOOST_CHECK(boost::filesystem::exists( "testDataSet" ));
DataSet newDataSet("testDataSet");
......
......@@ -9,7 +9,6 @@
#include <boost/test/unit_test.hpp>
#include "../ErrorFunction/ErrorFunctions.h"
#include "../Neuron/NeuronLinear.h"
/**
* Boost testing suite for testing ErrorFunction.h
......@@ -17,9 +16,6 @@
*/
BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
/**
* Test of construction of MSE instance
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_Construction_Test) {
NeuralNetwork network;
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
......@@ -33,12 +29,9 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
BOOST_CHECK_NO_THROW(MSE mse(&network, &dataSet));
}
/**
* Test of MSE eval method
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_Eval_Test) {
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
......@@ -49,7 +42,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
data_vec.emplace_back(std::make_pair(inp, out));
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, 0, 2.5);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::UNITARY_WEIGHT, 2.5);
network.randomize_weights();
std::vector<size_t> net_input_neurons_indices(1);
std::vector<size_t> net_output_neurons_indices(1);
......@@ -60,19 +53,17 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
DataSet dataSet(&data_vec);
double weights[1] = {0};
std::vector<double> weights;
weights.push_back(1);
MSE mse(&network, &dataSet);
BOOST_CHECK_EQUAL(4, mse.eval(&weights[0]));
BOOST_CHECK_EQUAL(9, mse.eval(&weights));
}
/**
* Test of MSE get_dimension method
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_Get_dimension_test) {
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
......@@ -83,7 +74,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
data_vec.emplace_back(std::make_pair(inp, out));
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, 0, 2.5);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::UNITARY_WEIGHT, 2.5);
network.randomize_weights();
std::vector<size_t> net_input_neurons_indices(1);
std::vector<size_t> net_output_neurons_indices(1);
......@@ -96,19 +87,13 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
MSE mse(&network, &dataSet);
BOOST_CHECK_EQUAL(1, mse.get_dimension());
BOOST_CHECK_EQUAL(2, mse.get_dimension());
}
/**
* Test of construction of MSE_SUM instance
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Construction_Test) {
BOOST_CHECK_NO_THROW(ErrorSum mse_sum);
}
/**
* Test of MSE_SUM add_error_function method
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Add_Error_Function_Test) {
NeuralNetwork network;
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
......@@ -126,15 +111,11 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
BOOST_CHECK_NO_THROW(mse_sum.add_error_function(f));
}
/**
* Test of MSE_SUM eval method
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Eval_Test) {
ErrorSum mse_sum;
double weights[1] = {0};
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
......@@ -145,7 +126,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
data_vec.emplace_back(std::make_pair(inp, out));
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, 0, 2.5);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::UNITARY_WEIGHT, 2.5);
network.randomize_weights();
std::vector<size_t> net_input_neurons_indices(1);
std::vector<size_t> net_output_neurons_indices(1);
......@@ -160,18 +141,18 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
mse_sum.add_error_function(f);
BOOST_CHECK_EQUAL(4, mse_sum.eval(&weights[0]));
std::vector<double> weights;
weights.push_back(1);
BOOST_CHECK_EQUAL(9, mse_sum.eval(&weights));
}
/**
* Test of MSE_SUM get_dimension method
*/
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Get_Dimension_test) {
ErrorSum mse_sum;
BOOST_CHECK_EQUAL(0, mse_sum.get_dimension());
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
......@@ -182,7 +163,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
data_vec.emplace_back(std::make_pair(inp, out));
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, 0, 2.5);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::UNITARY_WEIGHT, 2.5);
network.randomize_weights();
std::vector<size_t> net_input_neurons_indices(1);
std::vector<size_t> net_output_neurons_indices(1);
......@@ -197,7 +178,8 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
mse_sum.add_error_function(f);
BOOST_CHECK_EQUAL(1, mse_sum.get_dimension());
BOOST_CHECK_EQUAL(2, mse_sum.get_dimension());
}
......
......@@ -9,7 +9,6 @@
#include <boost/test/unit_test.hpp>
#include "../Network/NeuralNetworkSum.h"
#include "../Neuron/NeuronLinear.h"
/**
* Boost testing suite for testing NeuralNetworkSum.h
......@@ -20,12 +19,10 @@ BOOST_AUTO_TEST_SUITE(NeuralNetworkSum_test)
* Test of creating new instance of NeuralNetworkSum
*/
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_constuction_test) {
//Test of none exception raise when creating new instance of NeuralNewtwork
BOOST_CHECK_NO_THROW(NeuralNetworkSum networkSum);
}
/**
* Test of add_network method
*/
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_add_network_test) {
NeuralNetwork network;
NeuralNetworkSum networkSum;
......@@ -33,17 +30,14 @@ BOOST_AUTO_TEST_SUITE(NeuralNetworkSum_test)
BOOST_CHECK_NO_THROW(networkSum.add_network(&network, 5));
}
/**
* Test of eval_single_weights method
*/
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_eval_single_weights_test) {
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, -1, 2.5);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::UNITARY_WEIGHT, 2.5);
std::vector<size_t> output_neuron_indices(1);
output_neuron_indices[0] = (size_t) 1;
......@@ -62,24 +56,21 @@ BOOST_AUTO_TEST_SUITE(NeuralNetworkSum_test)
NeuralNetworkSum networkSum;
networkSum.add_network(&network, 2);
networkSum.eval_single(input, output, &weights);
BOOST_CHECK_EQUAL(44, output.at(0));
networkSum.eval_single(input, output);
BOOST_CHECK_EQUAL(2, output.at(0));
}
/**
* Test of get_weights method
*/
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_get_weights_test) {
NeuralNetworkSum networkSum;
BOOST_CHECK_EQUAL(0, networkSum.get_n_weights());
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, -1, 2.5);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::NEXT_WEIGHT, 2.5);
networkSum.add_network(&network, 2);
......
This diff is collapsed.
......@@ -19,24 +19,23 @@ BOOST_AUTO_TEST_SUITE(neuronBinary_test)
/**
* Test of creating new instance of NeuronBinary
*/
BOOST_AUTO_TEST_CASE(neuronLinear_construction__test) {
NeuronBinary neuron(1.745);
//Test of correct value of activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
BOOST_AUTO_TEST_CASE(neuronBinary_construction_test) {
BOOST_CHECK_NO_THROW(NeuronBinary *neuron = new NeuronBinary());
}
/**
* Test of activate method
*/
BOOST_AUTO_TEST_CASE(neuronLinear_activate__test) {
NeuronBinary neuron(1.75);
neuron.activate();
BOOST_AUTO_TEST_CASE(neuronBinary_activate_test) {
NeuronBinary *neuron = new NeuronBinary();
//Test of correct state neuron
BOOST_CHECK_EQUAL(0.0, neuron.get_state());
neuron.set_potential(1.76);
neuron.activate();
//Another test of correct state of neuron
BOOST_CHECK_EQUAL(1.0, neuron.get_state());
BOOST_CHECK_EQUAL(0.0, neuron->activate(2.0, 3.0));
BOOST_CHECK_EQUAL(1.0, neuron->activate(3.0, 3.0));
BOOST_CHECK_EQUAL(1.0, neuron->activate(3.0, 2.0));
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../Neuron/NeuronConstant.h"
/**
* Boost testing suite for testing NeuronConstant.h
* doesn't test inherited methods
*/
BOOST_AUTO_TEST_SUITE(neuronConstant_test)
/**
* Test of creating new instance of NeuronConstant
*/
BOOST_AUTO_TEST_CASE(neuronConstant_construction_test) {
BOOST_CHECK_NO_THROW(NeuronConstant *neuron = new NeuronConstant(2.0));
BOOST_CHECK_NO_THROW(NeuronConstant *neuron = new NeuronConstant());
}
/**
* Test of activate method
*/
BOOST_AUTO_TEST_CASE(neuronConstant_activate__test) {
NeuronConstant *neuron = new NeuronConstant(2.0);
//Test of correct state after activate neuron
BOOST_CHECK_EQUAL(2.0, neuron->activate(8.0, 7.0));
NeuronConstant *neuron2 = new NeuronConstant();
//Test of correct state after activate neuron
BOOST_CHECK_EQUAL(0.0, neuron2->activate(8.0, 7.0));
}
/**
* Test of derivative methods
*/
BOOST_AUTO_TEST_CASE(neuronConstant_derivative_test) {
NeuronConstant *neuron = new NeuronConstant(2.0);
//Test of correct output of activation_function_get_derivative method
BOOST_CHECK_EQUAL(0.0, neuron->activation_function_eval_derivative(3.0, 2.0));
BOOST_CHECK_EQUAL(0.0, neuron->activation_function_eval_derivative_bias(3.0, 2.0));
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -19,36 +19,28 @@ BOOST_AUTO_TEST_SUITE(neuronLinear_test)
/**
* Test of creating new instance of NeuronLinear
*/
BOOST_AUTO_TEST_CASE(neuronLinear_construction__test) {