Commit 7ee89114 authored by Steven Murray's avatar Steven Murray
Browse files

Ported LoggerImplementationTest.cpp from CPPUNIT to gtest.

parent 167fae8d
/******************************************************************************
* castor/log/LoggerImplementationTest.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/log/LoggerImplementation.hpp"
#include <gtest/gtest.h>
#include <memory>
#include <sys/time.h>
namespace unitTests {
class castor_log_LoggerImplementationTest: public ::testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
}; // class LoggerImplementationTest
TEST_F(castor_log_LoggerImplementationTest, testLogMsgWithAllParams) {
using namespace castor::log;
std::auto_ptr<Logger> logger;
ASSERT_NO_THROW(logger.reset(new LoggerImplementation("unitttests")));
const int numParams = 1;
const Param params[1] = {Param("testParam", "valueOfTestParam")};
struct timeval timeStamp;
ASSERT_EQ(0, gettimeofday(&timeStamp, NULL));
ASSERT_NO_THROW(
logger->logMsg(
LOG_INFO,
"Calling logMsg() with all parameters",
numParams,
params,
timeStamp));
}
TEST_F(castor_log_LoggerImplementationTest, testLogMsgWithoutTimeStamp) {
using namespace castor::log;
std::auto_ptr<Logger> logger;
ASSERT_NO_THROW(logger.reset(new LoggerImplementation("unitttests")));
const int numParams = 1;
const Param params[1] = {Param("testParam", "valueOfTestParam")};
ASSERT_NO_THROW(
logger->logMsg(
LOG_INFO,
"Calling logMsg() without time stamp",
numParams,
params));
}
TEST_F(castor_log_LoggerImplementationTest, testLogMsgWithoutParamsOrTimeStamp) {
using namespace castor::log;
std::auto_ptr<Logger> logger;
ASSERT_NO_THROW(logger.reset(new LoggerImplementation("unitttests")));
ASSERT_NO_THROW(
logger->logMsg(
LOG_INFO,
"Calling logMsg() without parameters or time stamp"));
}
} // namespace unitTests
......@@ -27,6 +27,7 @@ cmake_minimum_required (VERSION 2.6)
add_executable(castorUnitTests
castorUnitTests.cpp
../castor/exception/ExceptionTest.cpp
../castor/log/LoggerImplementationTest.cpp
../castor/server/DaemonTest.cpp
../castor/tape/tapeserver/SCSI/DeviceTest.cpp
../castor/tape/tapeserver/SCSI/StructuresTest.cpp
......
Supports Markdown
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