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
00590f98
Commit
00590f98
authored
6 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
AcsCmdLine::str2DriveId now throws InvalidDriveId instead of InvalidArgument
parent
8410bdba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mediachanger/acs/AcsCmdLine.cpp
+9
-10
9 additions, 10 deletions
mediachanger/acs/AcsCmdLine.cpp
mediachanger/acs/AcsCmdLine.hpp
+11
-3
11 additions, 3 deletions
mediachanger/acs/AcsCmdLine.hpp
mediachanger/acs/AcsCmdLineTest.cpp
+10
-11
10 additions, 11 deletions
mediachanger/acs/AcsCmdLineTest.cpp
with
30 additions
and
24 deletions
mediachanger/acs/AcsCmdLine.cpp
+
9
−
10
View file @
00590f98
...
...
@@ -46,8 +46,7 @@ DRIVEID cta::mediachanger::acs::AcsCmdLine::str2DriveId(const std::string &str)
// The drive ID should consist of 4 components: ACS, LSM, Panel and Transport
if
(
4
!=
components
.
size
())
{
//cta::exception::InvalidArgument ex;
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Invalid number of components in drive ID"
": expected=4, actual="
<<
components
.
size
();
throw
ex
;
...
...
@@ -60,25 +59,25 @@ DRIVEID cta::mediachanger::acs::AcsCmdLine::str2DriveId(const std::string &str)
// Each of the 4 components must be between 1 and than 3 characters long
if
(
1
>
acsStr
.
length
()
||
3
<
acsStr
.
length
())
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Invalid ACS string length"
": expected=1..3, actual="
<<
acsStr
.
length
();
throw
ex
;
}
if
(
1
>
lsmStr
.
length
()
||
3
<
lsmStr
.
length
())
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Invalid LSM string length"
": expected=1..3, actual="
<<
lsmStr
.
length
();
throw
ex
;
}
if
(
1
>
panStr
.
length
()
||
3
<
panStr
.
length
())
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Invalid panel string length"
": expected=1..3, actual="
<<
panStr
.
length
();
throw
ex
;
}
if
(
1
>
drvStr
.
length
()
||
3
<
drvStr
.
length
())
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Invalid drive string length"
": expected=1..3, actual="
<<
drvStr
.
length
();
throw
ex
;
...
...
@@ -86,22 +85,22 @@ DRIVEID cta::mediachanger::acs::AcsCmdLine::str2DriveId(const std::string &str)
// Each of the 4 components must only contain numerals
if
(
!
onlyContainsNumerals
(
acsStr
))
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"ACS must only contain numerals: value="
<<
acsStr
;
throw
ex
;
}
if
(
!
onlyContainsNumerals
(
lsmStr
))
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"LSM must only contain numerals: value="
<<
acsStr
;
throw
ex
;
}
if
(
!
onlyContainsNumerals
(
panStr
))
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Panel must only contain numerals: value="
<<
acsStr
;
throw
ex
;
}
if
(
!
onlyContainsNumerals
(
drvStr
))
{
cta
::
exception
::
InvalidArgument
ex
;
InvalidDriveId
ex
;
ex
.
getMessage
()
<<
"Drive/Transport must only contain numerals: value="
<<
acsStr
;
throw
ex
;
...
...
This diff is collapsed.
Click to expand it.
mediachanger/acs/AcsCmdLine.hpp
+
11
−
3
View file @
00590f98
...
...
@@ -18,6 +18,8 @@
#pragma once
#include
"common/exception/Exception.hpp"
extern
"C"
{
#include
"acssys.h"
#include
"acsapi.h"
...
...
@@ -36,14 +38,20 @@ namespace acs {
class
AcsCmdLine
{
public:
/**
* Invalid drive identifier.
*/
struct
InvalidDriveId
:
public
exception
::
Exception
{
InvalidDriveId
(
const
std
::
string
&
context
=
""
,
const
bool
embedBacktrace
=
true
)
:
cta
::
exception
::
Exception
(
context
,
embedBacktrace
)
{}
};
/**
* Parses the specified string and returns the corresponding drive ID object.
*
* This method throws a cta::exception::InvalidArgument if the syntax of
* the string is invalid.
*
* @param str The string to be parsed.
* @return The drive ID object.
* @throw InvalidDriveId if the syntax of the string is invalid.
*/
static
DRIVEID
str2DriveId
(
const
std
::
string
&
str
);
...
...
This diff is collapsed.
Click to expand it.
mediachanger/acs/AcsCmdLineTest.cpp
+
10
−
11
View file @
00590f98
...
...
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"common/exception/InvalidArgument.hpp"
#include
"mediachanger/acs/AcsCmdLine.hpp"
#include
<gtest/gtest.h>
...
...
@@ -53,7 +52,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, goodDayStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
tooManyComponentsStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2:3:4:5"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -62,7 +61,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, tooManyComponentsStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
tooFewComponentsStr2DriveIdgoodDayStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2:3"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -71,7 +70,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, tooFewComponentsStr2DriveIdgoodDaySt
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
tooLongAcsComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1111:2:3:4"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -80,7 +79,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, tooLongAcsComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
tooLongLsmComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2222:3:4"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -89,7 +88,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, tooLongLsmComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
tooLongPanComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2:3333:4"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -98,7 +97,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, tooLongPanComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
tooLongDrvComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2:3:4444"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -107,7 +106,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, tooLongDrvComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
emptyAcsComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
":2:3:4"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -116,7 +115,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, emptyAcsComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
emptyLsmComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1::3:4"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -125,7 +124,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, emptyLsmComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
emptyPanComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2::4"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
/**
...
...
@@ -134,7 +133,7 @@ TEST_F(cta_mediachanger_acs_AcsCmdLineTest, emptyPanComponentStr2DriveId) {
TEST_F
(
cta_mediachanger_acs_AcsCmdLineTest
,
emptyDrvComponentStr2DriveId
)
{
using
namespace
cta
::
mediachanger
::
acs
;
const
std
::
string
str
(
"1:2:3:"
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
cta
::
exception
::
Invalid
Argument
);
ASSERT_THROW
(
AcsCmdLine
::
str2DriveId
(
str
),
AcsCmdLine
::
Invalid
DriveId
);
}
}
// namespace unitTests
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