while (left < string.size()) {
size_t right = string.find(from, left);
if (right == std::string_view::npos) {
- result.append(string.data() + left);
+ result.append(string.data() + left, string.size() - left);
break;
}
result.append(string.data() + left, right - left);
CHECK(util::replace_all("xabc", "abc", "defdef") == "xdefdef");
CHECK(util::replace_all("abcx", "abc", "defdef") == "defdefx");
CHECK(util::replace_all("xabcyabcz", "abc", "defdef") == "xdefdefydefdefz");
+ CHECK(util::replace_all(std::string_view("xaxbc", 4), "x", "y") == "yayb");
}
TEST_CASE("util::replace_first")