From cfb017f66a169d5a43ccc26720cdda2cb0875cfb Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 1 Oct 2019 17:29:36 +0200 Subject: [PATCH] fixed order --- slsSupportLib/include/ToString.h | 25 +++++++++++++++---------- slsSupportLib/tests/test-ToString.cpp | 6 ++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index 52b25a655..fa1ee0def 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -20,6 +20,17 @@ namespace sls { + +inline std::string ToString(const slsDetectorDefs::runStatus s){ + return slsDetectorDefs::runStatusType(s); +} + +// in case we already have a string +// causes a copy but might be needed in generic code +inline std::string ToString(const std::string& s){ + return s; +} + /** Convert std::chrono::duration with specified output unit */ template typename std::enable_if::value, std::string>::type @@ -73,6 +84,9 @@ ToString(const T &value) { return std::to_string(value); } + + + /** * For a container loop over all elements and call ToString on the element * Container is excluded @@ -177,17 +191,8 @@ ToString(const T &obj) { return obj.str(); } -/** - * Call ToString with a string, causes copy but might be needed - * in generic code. - */ -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 62d59462d..0f4160678 100644 --- a/slsSupportLib/tests/test-ToString.cpp +++ b/slsSupportLib/tests/test-ToString.cpp @@ -135,3 +135,9 @@ TEST_CASE("string to detectorType"){ REQUIRE(StringTo
("Gotthard2") == dt::GOTTHARD2); } +TEST_CASE("vec"){ + using rs = slsDetectorDefs::runStatus; + std::vector vec{rs::ERROR, rs::IDLE}; + REQUIRE(ToString(vec) == "[error, idle]"); +} +