Newer
Older
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
kra568
committed
#define BOOST_TEST_MODULE NeuralNetworkSum_test
kra568
committed
#include "../Network/NeuralNetworkSum.h"
MOCK_BASE_CLASS(mock_network, lib4neuro::NeuralNetwork)
{
MOCK_METHOD(get_subnet, 2)
MOCK_METHOD(add_neuron, 3)
MOCK_METHOD(add_connection_simple, 4)
MOCK_METHOD(add_existing_connection, 4)
MOCK_METHOD(copy_parameter_space, 1)
MOCK_METHOD(set_parameter_space_pointers, 1)
MOCK_METHOD(eval_single, 3)
MOCK_METHOD(add_to_gradient_single, 4)
MOCK_METHOD(randomize_weights, 0)
MOCK_METHOD(randomize_biases, 0)
MOCK_METHOD(randomize_parameters, 0)
MOCK_METHOD(get_n_inputs, 0)
MOCK_METHOD(get_n_outputs, 0)
MOCK_METHOD(get_n_weights, 0)
MOCK_METHOD(get_n_biases, 0)
MOCK_METHOD(get_neuron_bias_index, 1)
MOCK_METHOD(get_n_neurons, 0)
MOCK_METHOD(specify_input_neurons, 1)
MOCK_METHOD(specify_output_neurons, 1)
MOCK_METHOD(get_parameter_ptr_biases, 0)
MOCK_METHOD(get_parameter_ptr_weights, 0)
MOCK_METHOD(save_text, 1)
MOCK_METHOD(print_stats, 0)
MOCK_METHOD(print_weights, 0)
};
/**
* Boost testing suite for testing NeuralNetworkSum.h
*/
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);
}
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_add_network_test) {
mock_network network;
//NeuralNetwork network;
std::string po = "f(x,y,z,t) =x+y+z+t";
BOOST_CHECK_NO_THROW(networkSum.add_network(&network, po));
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_eval_single_weights_test) {
mock_network network;
MOCK_EXPECT(network.eval_single);
std::vector<double> input;
input.push_back(1);
std::vector<double> output;
output.push_back(1);
double weights = 5;
NeuralNetworkSum networkSum;
networkSum.eval_single(input, output);
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_get_weights_test) {
NeuralNetworkSum networkSum;
BOOST_CHECK_EQUAL(0, networkSum.get_n_weights());
mock_network network;
MOCK_EXPECT(network.get_n_weights).returns(1);
networkSum.add_network(&network, "f(x) =x");
BOOST_CHECK_EQUAL(1, networkSum.get_n_weights());
}