Skip to content
Snippets Groups Projects
Commit fb7d8730 authored by Martin Beseda's avatar Martin Beseda
Browse files

MERGE with voj0085 dev_cpp

parents 8cf3bf07 dae22758
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
#--------------------#
# Automatic settings #
#--------------------#
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
# Processing user variables
if (WITH_TIME_PROFILING)
......@@ -71,3 +74,7 @@ else ()
message ("Not Windows")
endif ()
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()
\ No newline at end of file
......@@ -26,6 +26,15 @@ add_library(particle_swarm SHARED
LearningMethods/ParticleSwarm.cpp
LearningMethods/ParticleSwarm.h)
add_library(boost_unit_test SHARED tests/boost_test_lib_dummy.cpp)
add_executable(neuron_test tests/neuron_test.cpp)
target_link_libraries(neuron_test boost_unit_test neuron)
add_executable(linear_neuron_test tests/NeuronLinear_test.cpp)
target_link_libraries(linear_neuron_test boost_unit_test neuron)
add_executable(test_cases main.cpp)
target_link_libraries(test_cases neuron particle_swarm boost_serialization)
\ No newline at end of file
target_link_libraries(test_cases neuron particle_swarm boost_serialization)
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE neuronLinear_test
#include <boost/test/unit_test.hpp>
#include "../Neuron/NeuronLinear.h"
/**
* Boost testing suite for testing NeuronLinear.h
* doesn't test inherit methods
*/
BOOST_AUTO_TEST_SUITE(neuronLinear_test)
BOOST_AUTO_TEST_CASE(neuronLinear_construction__test) {
NeuronLinear neuron(1.745, 784.4547);
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 784.4547);
};
BOOST_AUTO_TEST_SUITE_END()
//
// Created by David on 11.07.2018.
//
#define BOOST_TEST_MODULE neuron_test
#include <boost/test/included/unit_test.hpp>
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE neuron_test
#include <boost/test/unit_test.hpp>
#include "../Neuron/Neuron.h"
#include "../Neuron/NeuronLinear.h"
/**
* Boost testing suite for testing Neuron.h
* testing use NeuralLinear.h
*/
BOOST_AUTO_TEST_SUITE(neuron_test)
/**
* Test of saturation methods
*/
BOOST_AUTO_TEST_CASE(neuron_saturation_test) {
NeuronLinear neuron(0, 0);
BOOST_CHECK_EQUAL(neuron.is_saturated_in(), false);
BOOST_CHECK_EQUAL(neuron.is_saturated_out(), false);
neuron.set_saturation_in(123);
neuron.set_saturation_out(132);
BOOST_CHECK_EQUAL(neuron.is_saturated_in(), true);
BOOST_CHECK_EQUAL(neuron.is_saturated_out(), true);
neuron.adjust_saturation_in(-123);
neuron.adjust_saturation_out(-123);
BOOST_CHECK_EQUAL(neuron.is_saturated_in(), false);
BOOST_CHECK_EQUAL(neuron.is_saturated_out(), false);
};
/**
* Test of potencial methods
*/
BOOST_AUTO_TEST_CASE(neuron_potencial_test) {
NeuronLinear neuron(0, 0);
BOOST_CHECK_EQUAL(neuron.get_potential(), 0);
BOOST_CHECK_EQUAL(neuron.get_potential(), (size_t) 0);
neuron.set_potential(1.123456789);
BOOST_CHECK_EQUAL(neuron.get_potential(), 1.123456789);
neuron.adjust_potential(-0.123456789);
BOOST_CHECK_EQUAL(neuron.get_potential(), 1);
BOOST_CHECK_EQUAL(neuron.get_potential(), 1.0);
BOOST_CHECK_EQUAL(neuron.get_potential(), (size_t) 1);
};
/**
* Test of state methods
*/
BOOST_AUTO_TEST_CASE(neuron_state_test)
{
NeuronLinear neuron(0,0);
neuron.set_state(0.00000);
BOOST_CHECK_EQUAL(neuron.get_state(),0);
BOOST_CHECK_EQUAL(neuron.get_state(),(size_t)0);
neuron.set_state(1.123456789);
BOOST_CHECK_EQUAL(neuron.get_state(), 1.123456789);
neuron.set_state(-0.123456789);
BOOST_CHECK_EQUAL(neuron.get_state(), 1);
BOOST_CHECK_EQUAL(neuron.get_state(), 1.0);
BOOST_CHECK_EQUAL(neuron.get_state(), (size_t)1);
};
/**
* Test of activation function methods
*/
BOOST_AUTO_TEST_CASE(neuron_activation_function_test)
{
NeuronLinear neuron(0,0);
BOOST_CHECK_EQUAL(neuron.activation_function_get_n_parameters(), 0);
BOOST_CHECK_THROW(neuron.activation_function_get_parameter(0), std::out_of_range);
neuron.activation_function_set_parameter(0,41.154);
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 41.154);
BOOST_CHECK_EQUAL(neuron.activation_function_get_n_parameters(), 1);
};
/**
* TODO
*/
BOOST_AUTO_TEST_CASE(neuron_connection_in_test){
NeuronLinear neuron(0,0);
// ConnectionWeight weight = new ConnectionWeight()
// Connection con = new Connection( neuron, neuron , )
BOOST_CHECK_THROW(neuron.get_connections_in(), std::nullptr_t);
}
/**
* TODO
*/
BOOST_AUTO_TEST_CASE(neuron_destructor_test){
}
BOOST_AUTO_TEST_SUITE_END()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment