Commit 70ad73fd authored by Marco Amagliani's avatar Marco Amagliani

fix of several bugs in Test::report. It was not reporting some information because of bugs.

[git-p4: depot-paths = "//ReForm/ReForm/main/Base/": change = 13842]
parent 01907f1f
......@@ -2,6 +2,7 @@ set(my_headers
${CMAKE_CURRENT_SOURCE_DIR}/IChecksum.hh
${CMAKE_CURRENT_SOURCE_DIR}/ChecksumLogValueT.hh
${CMAKE_CURRENT_SOURCE_DIR}/types.hh
${CMAKE_CURRENT_SOURCE_DIR}/ReadValuesT.hh
${CMAKE_CURRENT_SOURCE_DIR}/StreamContainerT.hh
PARENT_SCOPE
)
......
......@@ -14,25 +14,6 @@
namespace Test {
namespace Checksum {
#if 0
// Returns a compare class for double.
const CompareT<double>* compare_double(double _tol)
{
struct CompareDouble : public CompareT<double>
{
CompareDouble(double _tol) : tol_(_tol) {}
virtual bool same(const double& _a, const double& _b) const
{
return std::fabs(_a - _b) <= tol_;
}
bool operator<(const CompareDouble& _oth) const { return tol_ < _oth.tol_; }
double tol_;
};
static std::set<CompareDouble> comp_dbl__;
return &(*comp_dbl__.emplace(_tol).first);
}
#endif
// Template instantiations.
template LogValueT<unsigned>;
......@@ -45,14 +26,10 @@ template LogValueT<std::string>;
// Check on the debug errors.
LogValueT<Count> chk_error(2, "Debug_errors", "ERROR: ");
// Check the time. No time means that the test has failed.
// Check the time.
LogValueT<double, DoubleEqual>
chk_time(2, "Time", "Test time =", DoubleEqual(2), "out.log");
// Check the time. No time means that the test has failed.
LogValueT<Count>
chk_fail(0, "Success", "Test time =", std::equal_to<Count>(), "out.log");
}//namespace Test
}//namespace Checksum
......
......@@ -11,6 +11,7 @@
#ifdef TEST_ON
#include "ChecksumLogValueT.hh"
#include "ReadValuesT.hh"
#include "StreamContainerT.hh"
#include <boost/filesystem.hpp>
......@@ -30,27 +31,13 @@ std::ostream& operator<<(std::ostream& _out_str, const std::vector<ValueT>& _val
return write_container(_out_str, _vals);
}
template <typename ValueT> std::vector<ValueT>
values(const std::string& _key, const char* const _flnm, const Path& _dir)
std::ostream& operator<<(std::ostream& _out_str, const std::vector<Count>& _vals)
{
std::ifstream istr((_dir / _flnm).string());
std::string line;
std::vector<ValueT> defcts;
while (std::getline(istr, line))
{
auto pos = line.find(_key);
if (pos == std::string::npos)
continue;
pos += _key.length();
std::stringstream str_dat(line.substr(pos));
defcts.push_back(ValueT());
str_dat >> defcts.back();
}
return defcts;
_out_str << '#' << _vals.size();
return _out_str;
}
}
}//namespace
// Class LogValueT
......@@ -68,8 +55,8 @@ template <typename ValueT, class CompareT>
Severity LogValueT<ValueT, CompareT>::compare(const Path& _dir0,
const Path& _dir1, std::stringstream& _os) const
{
auto list0 = values<ValueT>(key_, flnm_, _dir0);
auto list1 = values<ValueT>(key_, flnm_, _dir1);
auto list0 = read_values<ValueT>(key_, flnm_, _dir0);
auto list1 = read_values<ValueT>(key_, flnm_, _dir1);
if (list0.size() != list1.size())
{
_os << '#' << list0.size() << " #" << list1.size();
......@@ -93,7 +80,7 @@ template <typename ValueT, class CompareT>
Severity LogValueT<ValueT, CompareT>::report(const Path& _dir,
std::stringstream& _os) const
{
auto list = values<ValueT>(name(), flnm_, _dir);
auto list = read_values<ValueT>(key_, flnm_, _dir);
if (list.empty())
return 0;
_os << list;
......
// (C) Copyright 2016 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_READVALUEST_HH_INCLUDE
#define BASE_READVALUEST_HH_INCLUDE
#include <fstream>
#include <string>
#include <vector>
namespace Test {
namespace Checksum {
/*! Parse the input file looking for a string and at every occurrence reads the
value of type ValueT following the string.
Returns a vector with all the read values.
*/
template <typename ValueT> std::vector<ValueT>
read_values(const std::string& _key, const char* const _flnm, const Path& _dir)
{
std::ifstream istr((_dir / _flnm).string());
std::string line;
std::vector<ValueT> vals;
while (std::getline(istr, line))
{
auto pos = line.find(_key);
if (pos == std::string::npos)
continue;
pos += _key.length();
std::stringstream str_dat(line.substr(pos));
vals.push_back(ValueT());
str_dat >> vals.back();
}
return vals;
}
}//Checksum
}//Test
#endif//BASE_READVALUEST_HH_INCLUDE
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