Skip to content

Commit

Permalink
(String) Fix partition returning wrong middle value (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
csparker247 committed Jun 28, 2024
1 parent af3ac33 commit 107e9cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Unit tests
on:
workflow_dispatch:
push:
branches: ["develop"]
pull_request:
Expand Down
10 changes: 5 additions & 5 deletions core/include/vc/core/util/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ static inline auto partition(std::string_view s, std::string_view sep)
}

// Split into parts
const auto endPos = startPos + sep.size();
auto pre = std::string(s.substr(0, startPos));
auto mid = std::string(s.substr(startPos, endPos));
auto post = std::string(s.substr(endPos));
auto mid = std::string(s.substr(startPos, sep.size()));
auto post = std::string(s.substr(startPos + sep.size()));

// Return the parts
return {pre, mid, post};
Expand All @@ -244,8 +243,9 @@ static inline auto partition(std::string_view s, std::string_view sep)
/** @brief Convert an Integer to a padded string */
template <
typename Integer,
std::enable_if_t<std::is_integral<Integer>::value, bool> = true>
auto to_padded_string(Integer val, int padding, char fill = '0') -> std::string
std::enable_if_t<std::is_integral_v<Integer>, bool> = true>
auto to_padded_string(Integer val, const int padding, const char fill = '0')
-> std::string
{
std::stringstream stream;
stream << std::setw(padding) << std::setfill(fill) << val;
Expand Down

0 comments on commit 107e9cc

Please sign in to comment.