Commit 9cf222e3 authored by David Vojtek's avatar David Vojtek

new DESolver unit test + update of Task and Bug templates

parent f2d415f4
Summary
**Summary**
(Summarize the bug encountered concisely)
Steps to reproduce
**Steps to reproduce**
(How one can reproduce the issue - this is very important)
What is the current bug behavior?
**What is the current bug behavior?**
(What actually happens)
What is the expected correct behavior?
**What is the expected correct behavior?**
(What you should see instead)
Relevant logs and/or screenshots
**Relevant logs and/or screenshots**
(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)
Possible fixes
**Possible fixes**
(If you can, link to the line of code that might be responsible for the problem)
......
Summary
**Summary**
(Summarize the bug encountered concisely)
Associated classes
**Associated classes**
(Classes, which need to be modified, if any)
......
......@@ -87,5 +87,7 @@ target_link_libraries(particle_test boost_unit_test 4neuro)
add_executable(NeuralNetworkSum_test tests/NeuralNetworkSum_test.cpp)
target_link_libraries(NeuralNetworkSum_test boost_unit_test 4neuro)
add_executable(DESolver_test tests/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 <iostream>
#include <boost/test/output_test_stream.hpp>
#include "../Solvers/DESolver.h"
/**
* Boost testing suite for testing DESolver.h
*
*/
BOOST_AUTO_TEST_SUITE(DESolver_test)
/**
* Test of MultiIndex construction test
*/
BOOST_AUTO_TEST_CASE(MultiIndex_construction_test) {
BOOST_CHECK_NO_THROW(MultiIndex multiIndex(2));
}
/**
* Test of MultiIndex set_partial_deravitive method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_set_partial_derivative_test) {
MultiIndex multiIndex(2);
BOOST_CHECK_NO_THROW(multiIndex.set_partial_derivative(0, 1));
BOOST_CHECK_NO_THROW(multiIndex.set_partial_derivative(1, 2));
//BOOST_CHECK_THROW(multiIndex.set_partial_derivative(2, 3), std::out_of_range);
}
/**
* Testo of MultiIndex get_partial_derivative_degrees method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_get_partial_derivative_degrees_test) {
MultiIndex multiIndex(2);
multiIndex.set_partial_derivative(0, 1);
multiIndex.set_partial_derivative(1, 2);
BOOST_CHECK_EQUAL(1, multiIndex.get_partial_derivatives_degrees()->at(0));
BOOST_CHECK_EQUAL(2, multiIndex.get_partial_derivatives_degrees()->at(1));
}
/**
* Test of MultiIndex operator< method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_operator_test) {
MultiIndex multiIndex1(1);
multiIndex1.set_partial_derivative(0, 1);
MultiIndex multiIndex2(2);
multiIndex2.set_partial_derivative(0, 1);
multiIndex2.set_partial_derivative(1, 2);
MultiIndex multiIndex3(1);
multiIndex3.set_partial_derivative(0, 2);
BOOST_CHECK(multiIndex1.operator<(multiIndex2));
//BOOST_CHECK_THROW(multiIndex2.operator<(multiIndex1), std::out_of_range);
BOOST_CHECK(!multiIndex1.operator<(multiIndex1));
BOOST_CHECK(multiIndex1.operator<((multiIndex3)));
}
/**
* Test of MultiIndex toString method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_toString_test) {
MultiIndex multiIndex(2);
BOOST_CHECK_EQUAL("0, 0", multiIndex.to_string());
}
/**
* Test of MultiIndex get_degree method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_get_degree_test) {
MultiIndex multiIndex(2);
BOOST_CHECK_EQUAL(0, multiIndex.get_degree());
multiIndex.set_partial_derivative(0, 1);
multiIndex.set_partial_derivative(1, 3);
BOOST_CHECK_EQUAL(4, multiIndex.get_degree());
}
/**
* 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::test_tools::output_test_stream output;
{
cout_redirect guard(output.rdbuf());
DESolver deSolver(1,1,1,1);
}
BOOST_CHECK(output.is_equal("Differential Equation Solver with 1 equations\n--------------------------------------------------------------------------\nConstructing NN structure representing the solution [1 input neurons][1 inner neurons][1 output neurons]...\n adding a connection between input neuron 0 and inner neuron 0, weight index 0\n adding a connection between inner neuron 0 and output neuron 0, weight index 1\ndone\n\n"));
*/
}
/**
* 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();
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment