Commit 01907f1f authored by Martin Marinov's avatar Martin Marinov
Browse files

Some cosmetic changes to the test compare tool.

[git-p4: depot-paths = "//ReForm/ReForm/main/Base/": change = 13836]
parent 1247a3cd
...@@ -31,8 +31,7 @@ std::ostream& operator<<(std::ostream& _out_str, const std::vector<ValueT>& _val ...@@ -31,8 +31,7 @@ std::ostream& operator<<(std::ostream& _out_str, const std::vector<ValueT>& _val
} }
template <typename ValueT> std::vector<ValueT> template <typename ValueT> std::vector<ValueT>
get_values(const std::string& _key, const char* const _flnm, values(const std::string& _key, const char* const _flnm, const Path& _dir)
const boost::filesystem::path& _dir)
{ {
std::ifstream istr((_dir / _flnm).string()); std::ifstream istr((_dir / _flnm).string());
std::string line; std::string line;
...@@ -56,8 +55,7 @@ get_values(const std::string& _key, const char* const _flnm, ...@@ -56,8 +55,7 @@ get_values(const std::string& _key, const char* const _flnm,
// Class LogValueT // Class LogValueT
template <typename ValueT, class CompareT> template <typename ValueT, class CompareT>
LogValueT<ValueT, CompareT>::LogValueT LogValueT<ValueT, CompareT>::LogValueT(
(
unsigned _order, const char* _name, unsigned _order, const char* _name,
const char* _key, const char* _key,
const CompareT& _comp, const CompareT& _comp,
...@@ -67,13 +65,11 @@ LogValueT<ValueT, CompareT>::LogValueT ...@@ -67,13 +65,11 @@ LogValueT<ValueT, CompareT>::LogValueT
{} {}
template <typename ValueT, class CompareT> template <typename ValueT, class CompareT>
Severity LogValueT<ValueT, CompareT>::compare( Severity LogValueT<ValueT, CompareT>::compare(const Path& _dir0,
const boost::filesystem::path& _dir0, const Path& _dir1, std::stringstream& _os) const
const boost::filesystem::path& _dir1,
std::stringstream& _os) const
{ {
auto list0 = get_values<ValueT>(key_, flnm_, _dir0); auto list0 = values<ValueT>(key_, flnm_, _dir0);
auto list1 = get_values<ValueT>(key_, flnm_, _dir1); auto list1 = values<ValueT>(key_, flnm_, _dir1);
if (list0.size() != list1.size()) if (list0.size() != list1.size())
{ {
_os << '#' << list0.size() << " #" << list1.size(); _os << '#' << list0.size() << " #" << list1.size();
...@@ -94,11 +90,10 @@ Severity LogValueT<ValueT, CompareT>::compare( ...@@ -94,11 +90,10 @@ Severity LogValueT<ValueT, CompareT>::compare(
} }
template <typename ValueT, class CompareT> template <typename ValueT, class CompareT>
Severity LogValueT<ValueT, CompareT>::report( Severity LogValueT<ValueT, CompareT>::report(const Path& _dir,
const boost::filesystem::path& _dir,
std::stringstream& _os) const std::stringstream& _os) const
{ {
auto list = get_values<ValueT>(name(), flnm_, _dir); auto list = values<ValueT>(name(), flnm_, _dir);
if (list.empty()) if (list.empty())
return 0; return 0;
_os << list; _os << list;
......
...@@ -70,12 +70,10 @@ public: ...@@ -70,12 +70,10 @@ public:
//*!<[in] File to parse to get the information. //*!<[in] File to parse to get the information.
); );
virtual Severity compare( virtual Severity report(const Path& _dir, std::stringstream& _os) const;
const boost::filesystem::path& _dir0, const boost::filesystem::path& _dir1,
std::stringstream& _os) const;
virtual Severity report( virtual Severity compare(const Path& _dir0, const Path& _dir1,
const boost::filesystem::path& _dir, std::stringstream& _os) const; std::stringstream& _os) const;
private: private:
CompareT comp_; // Compare class. CompareT comp_; // Compare class.
......
...@@ -32,38 +32,40 @@ must be instantiated as global variable in such a way that they are always avail ...@@ -32,38 +32,40 @@ must be instantiated as global variable in such a way that they are always avail
*/ */
class IChecksum class IChecksum
{ {
protected:
/*!Performs an automatic registration of the new checksum in a
global list, and verifies that the name is unique.
*/
IChecksum(unsigned _order, const char* _name);
public: public:
/*!Checksum name. //! Checksum name.
*/
const char* name() const { return name_; } const char* name() const { return name_; }
/*!Override compare to perform a comparison of the results stored in /*!
directories _dir0 and _dir1. Override report to log any "interesting value" that the check has in
Returns an estimation of the difference between the two test run.
*/
virtual Severity compare(
const Test::Path& _dir0, //!< [in] Directory with the reference result
const Test::Path& _dir1, //!< [in] Directory with the new result
std::stringstream& _os //!< [out] Description of the difference.
) const = 0;
/*!Override report to log any "interesting value" that the check has in
directory _dir. For example a number of face defects greater that 0. directory _dir. For example a number of face defects greater that 0.
Return an estimation of the severity. Return an estimation of the severity.
*/ */
virtual Severity report( virtual Severity report(
const Test::Path& _dir, //!< [in] Directory with the date to report. const Path& _dir, //!< [in] Directory with the date to report.
std::stringstream& _os //!< [out] Description of the retrieved information. std::stringstream& _os //!< [out] Description of the retrieved information.
) const = 0; ) const = 0;
/*!
Override compare to perform a comparison of the results stored in
directories _dir0 and _dir1.
Returns an estimation of the difference between the two test run.
*/
virtual Severity compare(
const Path& _dir0, //!< [in] Directory with the reference result
const Path& _dir1, //!< [in] Directory with the new result
std::stringstream& _os //!< [out] Description of the difference.
) const = 0;
protected:
/*!
Performs an automatic registration of the new checksum in a
global list, and verifies that the name is unique.
*/
IChecksum(unsigned _order, const char* _name);
private: private:
const char * name_; const char* name_;
}; };
/*! /*!
...@@ -86,4 +88,3 @@ const Registry& registry(); ...@@ -86,4 +88,3 @@ const Registry& registry();
#endif//TEST_ON #endif//TEST_ON
#endif//BASE_ICHECKSUM_HH_INCLUDE #endif//BASE_ICHECKSUM_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