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

Added DriveCatalogue::driveState2Str()

parent 5a7e6e56
Branches
Tags
No related merge requests found
......@@ -28,6 +28,20 @@
#include <string.h>
//-----------------------------------------------------------------------------
// driveState2Str
//-----------------------------------------------------------------------------
const char *castor::tape::tapeserver::daemon::DriveCatalogue::driveState2Str(
const DriveState state) const throw() {
switch(state) {
case DRIVE_STATE_INIT: return "INIT";
case DRIVE_STATE_DOWN: return "DOWN";
case DRIVE_STATE_UP: return "UP";
case DRIVE_STATE_RUNNING: return "RUNNING";
default: return "UNKNOWN";
}
}
//-----------------------------------------------------------------------------
// populateCatalogue
//-----------------------------------------------------------------------------
......
......@@ -94,6 +94,18 @@ public:
enum DriveState { DRIVE_STATE_INIT, DRIVE_STATE_DOWN, DRIVE_STATE_UP,
DRIVE_STATE_RUNNING };
/**
* Returns the string representation of the specified tape-drive state.
*
* Please note that this method does not throw an exception and to that end
* will return the string "UNKNOWN" if the string representation of the
* specified drive state is unknown.
*
* @param state The numerical tape-drive state.
* @return The string representation if known else "UNKNOWN".
*/
const char *driveState2Str(const DriveState state) const throw();
/**
* Poplates the catalogue using the specified parsed lines from
* /etc/castor/TPCONFIG.
......
......@@ -39,6 +39,21 @@ protected:
}
};
TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, driveState2Str) {
using namespace castor::tape::tapeserver::daemon;
DriveCatalogue catalogue;
ASSERT_EQ(std::string("INIT"),
catalogue.driveState2Str(DriveCatalogue::DRIVE_STATE_INIT));
ASSERT_EQ(std::string("DOWN"),
catalogue.driveState2Str(DriveCatalogue::DRIVE_STATE_DOWN));
ASSERT_EQ(std::string("UP"),
catalogue.driveState2Str(DriveCatalogue::DRIVE_STATE_UP));
ASSERT_EQ(std::string("RUNNING"),
catalogue.driveState2Str(DriveCatalogue::DRIVE_STATE_RUNNING));
}
TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, goodDayPopulate) {
using namespace castor::tape::tapeserver::daemon;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment