File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
iceoryx_hoofs/test/moduletests Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,35 @@ TEST_F(convert_test, fromString_LongInt_Fail)
313313 ASSERT_THAT (result.has_value (), Eq (false ));
314314}
315315
316+ TEST_F (convert_test, fromString_Integer_InvalidTrailingChar_Fail)
317+ {
318+ ::testing::Test::RecordProperty (" TEST_ID" , " 6a70f10f-227b-4b0a-8149-e5ca3c793b5d" );
319+
320+ using IntegerType = std::tuple<signed char ,
321+ short ,
322+ int ,
323+ long ,
324+ long long ,
325+ unsigned char ,
326+ unsigned short ,
327+ unsigned int ,
328+ unsigned long ,
329+ unsigned long long >;
330+ std::vector<std::string> invalid_input = {" 42a" , " 74 " , " -52-" };
331+
332+ // a lambda to iterate all invalid_input cases converting to type decltype(dummy)
333+ auto expect_failure = [&invalid_input](auto dummy) {
334+ using T = decltype (dummy);
335+ for (const auto & v : invalid_input)
336+ {
337+ auto invalid_ret = iox::convert::from_string<T>(v.c_str ());
338+ ASSERT_THAT (invalid_ret.has_value (), Eq (false ));
339+ }
340+ };
341+
342+ std::apply ([&](auto ... args) { (..., expect_failure (args)); }, IntegerType{});
343+ }
344+
316345// / SINGED INTEGRAL EDGE CASES START
317346// / inc: increment, dec: decrement
318347
You can’t perform that action at this time.
0 commit comments