diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index f5784f3d2..5a5da95ec 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -11,6 +11,7 @@ #include "TypeTraits.h" #include "sls_detector_exceptions.h" #include "string_utils.h" +#include "sls_detector_defs.h" #include #include #include @@ -174,9 +175,13 @@ ToString(const T &obj) { * Call ToString with a string, causes copy but might be needed * in generic code. */ -template <> -inline std::string ToString(const std::string& s){ +inline std::string ToString(const std::string& s){ return s; } +inline std::string ToString(slsDetectorDefs::runStatus s){ + return slsDetectorDefs::runStatusType(s); +} + + } // namespace sls diff --git a/slsSupportLib/tests/test-ToString.cpp b/slsSupportLib/tests/test-ToString.cpp index 0c295ce09..9f8da0832 100644 --- a/slsSupportLib/tests/test-ToString.cpp +++ b/slsSupportLib/tests/test-ToString.cpp @@ -1,6 +1,7 @@ #include "TimeHelper.h" #include "ToString.h" #include "network_utils.h" +#include "sls_detector_defs.h" #include "catch.hpp" #include #include @@ -111,5 +112,15 @@ TEST_CASE("vector of strings"){ } +TEST_CASE("run status"){ + using defs = slsDetectorDefs; + REQUIRE(ToString(defs::runStatus::ERROR) == "error"); + REQUIRE(ToString(defs::runStatus::WAITING) == "waiting"); + REQUIRE(ToString(defs::runStatus::TRANSMITTING) == "data"); //?? + REQUIRE(ToString(defs::runStatus::RUN_FINISHED) == "finished"); + REQUIRE(ToString(defs::runStatus::STOPPED) == "stopped"); + REQUIRE(ToString(defs::runStatus::IDLE) == "idle"); +} +