Skip to content
Snippets Groups Projects
Commit e6cc249a authored by Steven Murray's avatar Steven Murray
Browse files

Improved the unittests for castor::Log::Logger().

parent 93866459
No related branches found
No related tags found
No related merge requests found
......@@ -151,9 +151,8 @@ castor::log::Param::Param(const std::string &name, const double value)
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::log::Param::Param(const std::string &name,
const castor::stager::TapeVid &value) throw():
m_name(name), m_type(LOG_MSG_PARAM_TPVID),
castor::log::Param::Param(const castor::stager::TapeVid &value) throw():
m_name("TPVID"), m_type(LOG_MSG_PARAM_TPVID),
m_strValue(0 != value.vid() ? value.vid() : ""), m_intValue(0),
m_uint64Value(0), m_doubleValue(0.0), m_uuidValue(nullCuuid) {
}
......
......@@ -98,7 +98,7 @@ public:
/**
* Constructor for Tape VIDS.
*/
Param(const std::string &name, const castor::stager::TapeVid &value) throw();
Param(const castor::stager::TapeVid &value) throw();
/**
* Constructor for Raw parameters.
......
......@@ -27,6 +27,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <memory>
#include <sys/time.h>
namespace castor {
namespace log {
......@@ -56,8 +57,67 @@ public:
}
}
void testLogMsgWithAllParams() {
std::auto_ptr<Logger> logger;
CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Constructing logger",
logger.reset(new LoggerImplementation("unitttests")));
const int numParams = 1;
const Param params[1] = {Param("testParam", "valueOfTestParam")};
struct timeval timeStamp;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"gettimeofday()",
0,
gettimeofday(&timeStamp, NULL));
CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Calling logMsg() with all parameters",
logger->logMsg(
LOG_INFO,
"Calling logMsg() with all parameters",
numParams,
params,
timeStamp));
}
void testLogMsgWithoutTimeStamp() {
std::auto_ptr<Logger> logger;
CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Constructing logger",
logger.reset(new LoggerImplementation("unitttests")));
const int numParams = 1;
const Param params[1] = {Param("testParam", "valueOfTestParam")};
CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Calling logMsg() without time stamp",
logger->logMsg(
LOG_INFO,
"Calling logMsg() without time stamp",
numParams,
params));
}
void testLogMsgWithoutParamsOrTimeStamp() {
std::auto_ptr<Logger> logger;
CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Constructing logger",
logger.reset(new LoggerImplementation("unitttests")));
CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Calling logMsg() without parameters or time stamp",
logger->logMsg(
LOG_INFO,
"Calling logMsg() without parameters or time stamp"));
}
CPPUNIT_TEST_SUITE(LoggerImplementationTest);
CPPUNIT_TEST(testConstructorTooLongProgramName);
CPPUNIT_TEST(testLogMsgWithAllParams);
CPPUNIT_TEST(testLogMsgWithoutTimeStamp);
CPPUNIT_TEST(testLogMsgWithoutParamsOrTimeStamp);
CPPUNIT_TEST_SUITE_END();
};
......
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