Skip to content
Snippets Groups Projects
Commit 4aa8e527 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Finished conversion to boolean return value for runTest.

parent 18db28ef
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
#include <iostream>
#include <memory>
int TestBatchSimulation()
bool TestBatchSimulation()
{
SimulationFactory sim_registry;
const std::unique_ptr<GISASSimulation> simulation(sim_registry.createItem("MiniGISAS"));
......@@ -44,5 +44,5 @@ int TestBatchSimulation()
int main(int, char**)
{
return TestBatchSimulation();
return TestBatchSimulation() ? 0 : 1;
}
......@@ -36,7 +36,6 @@ CoreTest::~CoreTest()
bool CoreTest::runTest()
{
// Load reference if available
OutputData<double>* m_reference;
try {
m_reference = IntensityDataIOFactory::readOutputData(
FileSystem::GetJoinPath(CORE_STD_REF_DIR, getName() + ".int.gz"));
......
......@@ -38,6 +38,7 @@ public:
private:
GISASSimulation* m_simulation;
OutputData<double>* m_reference;
};
#endif // CORETEST_H
......@@ -46,7 +46,7 @@ IMinimizerTest::IMinimizerTest(const std::string& minimizer_name,
}
void IMinimizerTest::runTest()
bool IMinimizerTest::runTest()
{
std::unique_ptr<ISample> sample(createSample());
for (size_t i = 0; i < m_parameters.size(); ++i)
......@@ -69,16 +69,17 @@ void IMinimizerTest::runTest()
m_parameters[i].m_found_value = valuesAtMinimum[i];
// analyze results
bool success = true;
for (size_t i = 0; i < m_parameters.size(); ++i) {
double diff = std::abs(m_parameters[i].m_found_value - m_parameters[i].m_real_value)
/ m_parameters[i].m_real_value;
if (diff > m_parameter_tolerance)
m_result = FAILED;
std::cout << boost::format("%|12t| %-10s : %-6.4f (diff %6.4g) \n") %
m_parameters[i].m_name % m_parameters[i].m_found_value % diff;
success = false;
std::cout << boost::format("%|12t| %-10s : %-6.4f (diff %6.4g) %s\n") %
m_parameters[i].m_name % m_parameters[i].m_found_value % diff %
(success ? "OK" : "FAILED");
}
std::cout << getName() << " | " << getDescription() << " | " << getTestResultString() << "\n";
return success;
}
std::unique_ptr<FitSuite> IMinimizerTest::createFitSuite()
......@@ -89,11 +90,10 @@ std::unique_ptr<FitSuite> IMinimizerTest::createFitSuite()
m_minimizer_name, m_minimizer_algorithm);
minimizer->getOptions()->setMaxIterations(200);
result->setMinimizer(minimizer);
for (size_t i = 0; i < m_parameters.size(); ++i) {
for (size_t i = 0; i < m_parameters.size(); ++i)
result->addFitParameter(
m_parameters[i].m_name, m_parameters[i].m_start_value,
AttLimits::lowerLimited(0.01), m_parameters[i].m_start_value / 100.);
}
return result;
}
......
......@@ -35,7 +35,7 @@ public:
const std::string &minimizer_algorithm = std::string());
virtual ~IMinimizerTest(){}
void runTest();
bool runTest() final;
class TestParameter
{
......@@ -53,7 +53,7 @@ protected:
virtual std::unique_ptr<FitSuite> createFitSuite();
virtual std::unique_ptr<ISample> createSample();
virtual std::unique_ptr<GISASSimulation> createSimulation();
virtual std::unique_ptr<OutputData<double> > createOutputData(const GISASSimulation *simulation);
virtual std::unique_ptr<OutputData<double>> createOutputData(const GISASSimulation* simulation);
std::vector<TestParameter> m_parameters;
std::string m_minimizer_name;
......
......@@ -34,7 +34,7 @@ PyPersistenceTest::PyPersistenceTest(
{}
//! Runs a Python script, and returns true if the output of the script agrees with reference data.
void PyPersistenceTest::runTest()
bool PyPersistenceTest::runTest()
{
std::string dat_stem = FileSystem::GetJoinPath(PYPERSIST_OUT_DIR, getName());
std::string ref_stem = FileSystem::GetJoinPath(PYPERSIST_REF_DIR, getName());
......@@ -122,7 +122,7 @@ bool PyPersistenceTest::compareIntensityPair(
{
const OutputData<double>* dat = IntensityDataIOFactory::readOutputData( dat_fpath );
const OutputData<double>* ref = IntensityDataIOFactory::readOutputData( ref_fpath );
return compareIntensityMaps(*dat, *ref)==SUCCESS;
return compareIntensityMaps(*dat, *ref);
}
//! Returns true if YAML files from test output and reference agree.
......
......@@ -73,12 +73,13 @@ bool IStandardTest::execute_subtests()
for (size_t i = 0; i < n_subtests; ++i) {
setName( m_info->m_test_name + "_" + subtest_names[i] );
m_subtest_item = subtest_registry->getItem(subtest_names[i]);
IFunctionalTest* subtest( getTest() );
std::cout << "IStandardTest::execute() -> " << getName()
<< " " << i+1 << "/" << n_subtests << " (" << subtest_names[i] << ")\n";
if(!subtest->runTest()) {
++number_of_failed_tests;
delete subtest;
delete subtest;
}
}
delete subtest_registry;
......
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