mirror of https://github.com/polybar/polybar.git
fix(string_util): Proper squeezing
This commit is contained in:
parent
4d24097092
commit
d7d953d40a
|
@ -55,7 +55,10 @@ namespace string_util {
|
|||
* Replace all occurences of needle in haystack
|
||||
*/
|
||||
inline auto replace_all(const string& haystack, string needle, string replacement) {
|
||||
return boost::replace_all_copy(haystack, needle, replacement);
|
||||
auto result = haystack;
|
||||
while (result.find(needle) != string::npos)
|
||||
result = replace(result, needle, replacement);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,8 @@ class test_string : public unit_test {
|
|||
}
|
||||
|
||||
void test_squeeze() {
|
||||
CPPUNIT_ASSERT_EQUAL(string{"Squeeeze"}, string_util::squeeze("Squeeeeeze", 'e'));
|
||||
CPPUNIT_ASSERT_EQUAL(string{"Squeze"}, string_util::squeeze("Squeeeeeze", 'e'));
|
||||
CPPUNIT_ASSERT_EQUAL(string{"bar baz foobar"}, string_util::squeeze("bar baz foobar", ' '));
|
||||
}
|
||||
|
||||
void test_strip() {
|
||||
|
|
Loading…
Reference in New Issue