Skip to content
Snippets Groups Projects
Commit 6601a925 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Changed asserts for std::runtime_error in converter.h

parent c3eab824
No related branches found
No related tags found
No related merge requests found
Pipeline #3698 passed
......@@ -97,7 +97,7 @@ namespace wolf{
template<typename T>
struct converter{
static T convert(std::string val){
assert(1 == 0 && "There is no general convert for arbitrary T !!!");
throw std::runtime_error("There is no general convert for arbitrary T !!! String provided: "+ val);
}
};
template<typename A>
......@@ -160,8 +160,7 @@ struct converter<std::string>{
}
template<typename T>
static std::string convert(T val){
assert(1 == 0 && "There is no general convert to string for arbitrary T !!!");
return "";
throw std::runtime_error("There is no general convert to string for arbitrary T !!! String provided: " + val);
}
static std::string convert(int val){
return std::to_string(val);
......
......@@ -49,7 +49,11 @@ TEST(Converter, ParseToMap)
map<string, vector<int>> m = {{"x",vector<int>{1,2}}, {"y",vector<int>{}}, {"z",vector<int>{3}}};
ASSERT_EQ(converter<string>::convert(m), "[{x:[1,2]},{y:[]},{z:[3]}]");
}
TEST(Converter, noGeneralConvert)
{
class DUMMY{};
EXPECT_THROW(([=]{converter<DUMMY>::convert("Should fail");}()), std::runtime_error);
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment