Newer
Older
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
kra568
committed
#define BOOST_TEST_MODULE NeuralNetworkSum_test
kra568
committed
#ifdef _WINDOWS
#include <boost/test/included/unit_test.hpp>
#else
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
kra568
committed
#include <boost/test/output_test_stream.hpp>
#endif
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "../Network/NeuralNetworkSum.h"
/**
* 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) {
NeuralNetwork network;
NeuralNetworkSum networkSum;
BOOST_CHECK_NO_THROW(networkSum.add_network(&network, 5));
}
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_eval_single_weights_test) {
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
network.add_neuron(n1);
network.add_neuron(n2);
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;
network.specify_output_neurons(output_neuron_indices);
std::vector<size_t> input_neuron_indices(1);
input_neuron_indices[0] = (size_t) 0;
network.specify_input_neurons(input_neuron_indices);
std::vector<double> input;
input.push_back(1);
std::vector<double> output;
output.push_back(1);
double weights = 5;
NeuralNetworkSum networkSum;
networkSum.add_network(&network, 2);
networkSum.eval_single(input, output);
BOOST_CHECK_EQUAL(2, output.at(0));
}
BOOST_AUTO_TEST_CASE(NeuralNetworkSum_get_weights_test) {
NeuralNetworkSum networkSum;
BOOST_CHECK_EQUAL(0, networkSum.get_n_weights());
Neuron *n1 = new NeuronLinear();
Neuron *n2 = new NeuronLinear();
NeuralNetwork network;
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0, 1, SIMPLE_CONNECTION_TYPE::NEXT_WEIGHT, 2.5);
networkSum.add_network(&network, 2);
BOOST_CHECK_EQUAL(1, networkSum.get_n_weights());
}
BOOST_AUTO_TEST_SUITE_END()