diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3c284da..6df81f4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -60,7 +60,7 @@ jobs: - name: Generate coverage report run: | - lcov -d . -c -o out.info --rc lcov_branch_coverage=1 --no-external + lcov -d . -c -o out.info --rc lcov_branch_coverage=1 --no-external --filter branch --filter line lcov -e out.info '*include/ss*hpp' -o filtered.info - name: Invoke coveralls diff --git a/include/ss/parser.hpp b/include/ss/parser.hpp index a7319ee..ac6f204 100644 --- a/include/ss/parser.hpp +++ b/include/ss/parser.hpp @@ -368,20 +368,22 @@ public: template void try_convert_and_invoke(std::optional& value, Fun&& fun) { - if (!parser_.valid()) { - auto tuple_output = try_same(); - if (!parser_.valid()) { - return; - } - - if constexpr (!std::is_same_v) { - value = to_object(std::move(tuple_output)); - } else { - value = std::move(tuple_output); - } - - parser_.try_invoke(*value, std::forward(fun)); + if (parser_.valid()) { + return; } + + auto tuple_output = try_same(); + if (!parser_.valid()) { + return; + } + + if constexpr (!std::is_same_v) { + value = to_object(std::move(tuple_output)); + } else { + value = std::move(tuple_output); + } + + parser_.try_invoke(*value, std::forward(fun)); } template @@ -918,6 +920,7 @@ private: } size_t remove_eol(char*& buffer, size_t ssize) { + // TODO write unit tests if (buffer[ssize - 1] != '\n') { return ssize; } @@ -940,7 +943,8 @@ private: buffer_size = first_size + second_size + 3; auto new_first = static_cast( realloc(static_cast(first), buffer_size)); - if (!first) { + // TODO check + if (!new_first) { throw std::bad_alloc{}; } diff --git a/test/test_helpers.hpp b/test/test_helpers.hpp index d5afeae..8df69d9 100644 --- a/test/test_helpers.hpp +++ b/test/test_helpers.hpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #ifdef CMAKE_GITHUB_CI #include @@ -134,7 +136,7 @@ template for (const auto& i : v) { for (auto j : inner_combinations) { j.insert(j.begin(), i); - ret.push_back(move(j)); + ret.push_back(std::move(j)); } } return ret;