diff --git a/lib/utils/mu-test-utils.hh b/lib/utils/mu-test-utils.hh index f6f5e78b..0774f79c 100644 --- a/lib/utils/mu-test-utils.hh +++ b/lib/utils/mu-test-utils.hh @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2023 Dirk-Jan C. Binnema +** Copyright (C) 2008-2025 Dirk-Jan C. Binnema ** ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -77,6 +78,21 @@ const char* set_tz(const char* tz); bool set_en_us_utf8_locale(); + +/** + * Count new lines in string. + * + * @param s string + * + * @return number of newlines + */ +static inline size_t count_nl(const std::string& s) { + return std::count(s.begin(), s.end(), '\n'); +} + + + + /** * For unit tests, assert two std::string's are equal. * diff --git a/mu/mu-cmd-find.cc b/mu/mu-cmd-find.cc index 3556b454..d4c7e172 100644 --- a/mu/mu-cmd-find.cc +++ b/mu/mu-cmd-find.cc @@ -533,14 +533,6 @@ Mu::mu_cmd_find(const Store& store, const Options& opts) static std::string test_mu_home; -auto count_nl(const std::string& s)->size_t { - size_t n{}; - for (auto&& c: s) - if (c == '\n') - ++n; - return n; -} - static size_t search_func(const std::string& expr, size_t expected) {