fmt: add some unit tests and fix fmt::trim

This commit is contained in:
Megamouse 2025-04-29 22:54:19 +02:00
parent 376ac85029
commit 68e7f4e820
2 changed files with 158 additions and 4 deletions

View file

@ -824,7 +824,12 @@ std::string fmt::trim(const std::string& source, std::string_view values)
if (begin == source.npos)
return {};
return source.substr(begin, source.find_last_not_of(values) + 1);
const usz end = source.find_last_not_of(values);
if (end == source.npos)
return source.substr(begin);
return source.substr(begin, end + 1 - begin);
}
std::string fmt::trim_front(const std::string& source, std::string_view values)