diff --git a/gcovr.cfg b/gcovr.cfg index 4e242a4..3920172 100644 --- a/gcovr.cfg +++ b/gcovr.cfg @@ -1,4 +1,5 @@ exclude-throw-branches = yes +exclude-unreachable-branches = yes filter = include/mav exclude = include/mav/rapidxml/* exclude = include/mav/picosha2/* \ No newline at end of file diff --git a/include/mav/MessageSet.h b/include/mav/MessageSet.h index ff34ebf..72757db 100644 --- a/include/mav/MessageSet.h +++ b/include/mav/MessageSet.h @@ -130,7 +130,7 @@ namespace mav { } - static bool _isPrefix(std::string_view prefix, std::string_view full) { + static bool _isPrefix(std::string_view prefix, std::string_view full) noexcept { return prefix == full.substr(0, prefix.size()); } diff --git a/tests/MessageSet.cpp b/tests/MessageSet.cpp index 6a1874b..48e89ad 100644 --- a/tests/MessageSet.cpp +++ b/tests/MessageSet.cpp @@ -194,7 +194,7 @@ TEST_CASE("Enum value encoding") { CHECK_THROWS_AS(message_set.addFromXMLString(empty_value), mav::ParseError); } - SUBCASE("Enum with invalid value") { + SUBCASE("Enum with invalid value 1") { std::string invalid_value = R""""( @@ -209,6 +209,35 @@ TEST_CASE("Enum value encoding") { CHECK_THROWS_AS(message_set.addFromXMLString(invalid_value), mav::ParseError); } + SUBCASE("Enum with invalid value 2") { + std::string invalid_value = R""""( + + + + + + + +)""""; + + MessageSet message_set; + CHECK_THROWS_AS(message_set.addFromXMLString(invalid_value), mav::ParseError); + } + + SUBCASE("Enum with invalid value 3") { + std::string invalid_value = R""""( + + + + + + + +)""""; + + MessageSet message_set; + CHECK_THROWS_AS(message_set.addFromXMLString(invalid_value), mav::ParseError); + } SUBCASE("Enum with overflow value") { std::string invalid_value = R""""( @@ -225,8 +254,20 @@ TEST_CASE("Enum value encoding") { CHECK_THROWS_AS(message_set.addFromXMLString(invalid_value), mav::ParseError); } + SUBCASE("Enum with non-base-2 exponential value") { + std::string invalid_value = R""""( + + + + + + + +)""""; - + MessageSet message_set; + CHECK_THROWS_AS(message_set.addFromXMLString(invalid_value), mav::ParseError); + } }