mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
fix for string to string conversion
This commit is contained in:
parent
3c6d7ca4a5
commit
ffa9bbe8d2
@ -170,4 +170,13 @@ ToString(const T &obj) {
|
|||||||
return obj.str();
|
return obj.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ToString with a string, causes copy but might be needed
|
||||||
|
* in generic code.
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline std::string ToString<std::string>(const std::string& s){
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -97,6 +97,11 @@ TEST_CASE("Convert types with str method"){
|
|||||||
REQUIRE(ToString(sls::IpAddr{}) == "0.0.0.0");
|
REQUIRE(ToString(sls::IpAddr{}) == "0.0.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("String to string", "[support]"){
|
||||||
|
std::string s = "hej";
|
||||||
|
REQUIRE(ToString(s) == "hej");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("vector of strings"){
|
TEST_CASE("vector of strings"){
|
||||||
std::vector<std::string> vec{"5", "s"};
|
std::vector<std::string> vec{"5", "s"};
|
||||||
REQUIRE(ToString(vec) == "[5, s]");
|
REQUIRE(ToString(vec) == "[5, s]");
|
||||||
@ -105,3 +110,6 @@ TEST_CASE("vector of strings"){
|
|||||||
REQUIRE(ToString(vec2) == "[some, strange, words, 75]");
|
REQUIRE(ToString(vec2) == "[some, strange, words, 75]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user