Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
329a398d
Commit
329a398d
authored
11 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Added the first CppUnit test for castor::log.
parent
d065f4a8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
castor/log/Log.cpp
+0
-5
0 additions, 5 deletions
castor/log/Log.cpp
castor/log/Log.hpp
+8
-2
8 additions, 2 deletions
castor/log/Log.hpp
test/unittest/castor/log/LogTest.cpp
+68
-0
68 additions, 0 deletions
test/unittest/castor/log/LogTest.cpp
with
76 additions
and
7 deletions
castor/log/Log.cpp
+
0
−
5
View file @
329a398d
...
...
@@ -60,11 +60,6 @@ const size_t LOG_MAX_PARAMNAMELEN = 20;
*/
const
size_t
LOG_MAX_PARAMSTRLEN
=
1024
;
/**
* Maximum length of the program name to be prepended to every log message.
*/
const
size_t
LOG_MAX_PROGNAMELEN
=
20
;
/**
* Maximum length of a log message.
*/
...
...
This diff is collapsed.
Click to expand it.
castor/log/Log.hpp
+
8
−
2
View file @
329a398d
...
...
@@ -50,11 +50,17 @@
namespace
castor
{
namespace
log
{
/**
* Maximum length of the program name to be prepended to every log message.
*/
const
size_t
LOG_MAX_PROGNAMELEN
=
20
;
/**
* Initialize the CASTOR logging interface.
*
* @param progname The name of the program to be prepended to every log
* message.
* @param progname The name of the program to be prepended to every log message.
* The name should not be longer than castor::log::LOG_MAX_PROGNAMELEN
* characters.
*/
void
initLog
(
const
std
::
string
&
progname
)
throw
(
castor
::
exception
::
AlreadyInitialized
,
castor
::
exception
::
Internal
,
...
...
This diff is collapsed.
Click to expand it.
test/unittest/castor/log/LogTest.cpp
0 → 100644
+
68
−
0
View file @
329a398d
/******************************************************************************
* test/unittest/castor/log/LogTest.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/Log.hpp"
#include
<cppunit/extensions/HelperMacros.h>
namespace
castor
{
namespace
log
{
class
LogTest
:
public
CppUnit
::
TestFixture
{
public:
void
setUp
()
{
}
void
tearDown
()
{
}
void
testInitLog
()
{
// Create a program name that is 1 character too long
std
::
string
tooLongProgname
;
for
(
size_t
i
=
0
;
i
<=
LOG_MAX_PROGNAMELEN
;
i
++
)
{
tooLongProgname
+=
'X'
;
}
CPPUNIT_ASSERT_THROW_MESSAGE
(
"Checking a program name that is too long throws InvalidArgument"
,
initLog
(
tooLongProgname
),
castor
::
exception
::
InvalidArgument
);
CPPUNIT_ASSERT_NO_THROW_MESSAGE
(
"Checking the first call to initLog() does not fail"
,
initLog
(
"LogTest"
));
CPPUNIT_ASSERT_THROW_MESSAGE
(
"Checking the second call to initLog() throws AlreadyInitialized"
,
initLog
(
"LogTest"
),
castor
::
exception
::
AlreadyInitialized
);
}
CPPUNIT_TEST_SUITE
(
LogTest
);
CPPUNIT_TEST
(
testInitLog
);
CPPUNIT_TEST_SUITE_END
();
};
CPPUNIT_TEST_SUITE_REGISTRATION
(
LogTest
);
}
// namespace log
}
// namespace castor
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment