Skip to content

Commit

Permalink
Strutils join const
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio3rs committed Aug 29, 2024
1 parent 1bb5f89 commit 389df32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/Strutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Strutils {
std::string("$1"));
}

static inline auto join(const std::span<std::string> &vec,
static inline auto join(const std::span<const std::string> &vec,
const std::string &term) -> std::string {
std::string result;
result.reserve(vec.size() * term.size());
Expand Down
4 changes: 4 additions & 0 deletions tests/test_strutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ TEST(TestStrutils, JoinTest) {
std::vector<std::string> vec5 = {};
std::string result5 = Strutils::join(vec5, " ");
EXPECT_EQ(result5, "");

const std::vector<std::string> cvec2 = {"apple", "banana", "cherry"};
std::string cresult2 = Strutils::join(vec2, ", ");
EXPECT_EQ(cresult2, "apple, banana, cherry");
}

0 comments on commit 389df32

Please sign in to comment.