Commit 007c9278 authored by Martin Marinov's avatar Martin Marinov
Browse files

Replace TEST_only() with Test. Introduce Test::Checksum::Level and run_lvl

parent 3e3a854e
......@@ -32,14 +32,14 @@ namespace Debug {
void warning(const std::string& _wrng, const Base::CodeLink& _lnk)
{
TEST_only(Test::Checksum::Debug::warning.record(_wrng, _lnk));
TEST(Test::Checksum::Debug::warning, record(_wrng, _lnk));
Stream strm(File::modify());
strm << WARNING << ": " << _wrng << ' ' << _lnk << Base::LF;
}
void error(const std::string& _err, const Base::CodeLink& _lnk)
{
TEST_only(Test::Checksum::Debug::error.record(_err, _lnk));
TEST(Test::Checksum::Debug::error, record(_err, _lnk));
Stream strm(File::modify());
strm << ERROR << ": " << _err << ' ' << _lnk << Base::Command::END_ERR;
}
......
......@@ -10,6 +10,8 @@
namespace Test {
namespace Checksum {
extern Level run_lvl = L_NONE;
namespace {
Registry& registry_modify()
......@@ -28,8 +30,8 @@ const Registry& registry()
///////////////////////////////////////////////////////////////////////////////
// class Checksum implementation
Object::Object(const char* _name)
: name_(_name)
Object::Object(const char* const _name, const Level _lvl)
: name_(_name), lvl_(_lvl)
{
auto pos = registry_modify().emplace(name_, this);
if (!pos.second)
......
......@@ -5,6 +5,8 @@
#ifndef TEST_ON
#define TEST(CHKSM, RCRD)
#else
#include <Base/Test/TestResult.hh>
......@@ -15,6 +17,10 @@
namespace Test {
namespace Checksum {
//! Enumerate the checksum levels
enum Level { L_NONE, L_PRIME, L_ALL };
extern Level run_lvl; //<! The checksum run level
//! typedef String, this is used a lot in this namespace
typedef std::string String;
......@@ -114,12 +120,6 @@ must be instantiated as global variables.
class Object
{
public:
/*!
Performs an automatic registration of the new checksum in a
global list, and verifies that the name is unique.
*/
Object(const char* const _name);
//! Checksum name.
const char* const name() const { return name_; }
......@@ -148,13 +148,25 @@ public:
const Record& _new_rcrd //!<[in] "Right" record
) const;
//! Get if the checksum should be run
bool allow() const { return lvl_ <= run_lvl; }
protected:
/*!
Performs an automatic registration of the new checksum in a
global list, and verifies that the name is unique.
*/
Object(const char* const _name, const Level _lvl = L_ALL);
//! Add a record of the checksum (protected version)
void add(const Result& _rslt, const String& _data);
//! Compare the data, the default implementation does a string comparison
virtual Difference compare_data(const String& _old, const String& _new) const;
protected:
const Level lvl_;
private:
const char* const name_;
......@@ -177,12 +189,9 @@ const Registry& registry();
}//namespace Checksum
}//namespace Test
#define TEST(CHKSM, RCRD) { if (CHKSM.allow()) { CHKSM.RCRD; } }
#endif//TEST_ON
#ifdef TEST_ALL
#define TEST_only(CC) CC
#else//TEST_ALL
#define TEST_only(CC)
#endif//TEST_ALL
#endif//BASE_ICHECKSUM_HH_INCLUDE
......@@ -21,7 +21,7 @@ namespace Checksum {
class Condition : public Object
{
public:
Condition() : Object("Condition"), nmbr_(0), fail_nmbr_(0) {}
Condition() : Object("Condition", L_PRIME), nmbr_(0), fail_nmbr_(0) {}
virtual void record(const char* const _cndt, const Base::CodeLink& _lnk,
const bool _rslt);
......
......@@ -19,7 +19,7 @@ public:
enum TagUsed { TAG_USED };
//! Make sure the constructor caller is aware of the tag requirement
File(const char* _name, TagUsed) : Object(_name) {}
File(const char* const _name, TagUsed) : Object(_name, L_PRIME) {}
void record(const char* _flnm);
......
......@@ -52,9 +52,9 @@ class NumberT : public Object
{
public:
NumberT(
const char* _name, //!<[in] Checksum name.
const char* const _name, //!<[in] Checksum name.
const CompareT& _comp = CompareT() //!<[in] Comparison function.
)
)
: Object(_name), comp_(_comp)
{}
......
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