Separating header for test_output

This commit is contained in:
Michael Tryby
2019-03-01 17:55:45 -05:00
parent 4bbf4e2b1e
commit 73a6c1c847
3 changed files with 77 additions and 67 deletions

View File

@@ -7,7 +7,7 @@
#include <boost/test/included/unit_test.hpp>
#include "epanet2_2.h"
#include "epanet_output.h"
// Custom test to check the minimum number of correct decimal digits between
@@ -46,40 +46,6 @@ boost::test_tools::predicate_result check_cdd_double(std::vector<double>& test,
return floor(min_cdd) >= cdd_tol;
}
boost::test_tools::predicate_result check_cdd_float(std::vector<float>& test,
std::vector<float>& ref, long cdd_tol){
float tmp, min_cdd = 10.0;
// TODO: What if the vectors aren't the same length?
std::vector<float>::iterator test_it;
std::vector<float>::iterator ref_it;
for (test_it = test.begin(), ref_it = ref.begin();
(test_it < test.end()) && (ref_it < ref.end());
++test_it, ++ref_it)
{
if (*test_it != *ref_it) {
// Compute log absolute error
tmp = abs(*test_it - *ref_it);
if (tmp < 1.0e-7f)
tmp = 1.0e-7f;
else if (tmp > 2.0f)
tmp = 1.0f;
tmp = -log10(tmp);
if (tmp < 0.0f)
tmp = 0.0f;
if (tmp < min_cdd)
min_cdd = tmp;
}
}
return floor(min_cdd) >= cdd_tol;
}
boost::test_tools::predicate_result check_string(std::string test, std::string ref)
{
if (ref.compare(test) == 0)
@@ -116,30 +82,3 @@ struct FixtureOpenClose{
int error;
EN_Project ph;
};
#define DATA_PATH_OUTPUT "./example1.out"
struct FixtureOutput{
FixtureOutput() {
path = std::string(DATA_PATH_OUTPUT);
error = ENR_init(&p_handle);
ENR_clearError(p_handle);
error = ENR_open(p_handle, path.c_str());
array = NULL;
array_dim = 0;
}
~FixtureOutput() {
free((void*)array);
error = ENR_close(&p_handle);
}
std::string path;
int error;
ENR_Handle p_handle;
float* array;
int array_dim;
};