diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2025-11-19 22:28:46 +0200 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2025-11-19 22:42:59 +0200 |
| commit | 6bba0458d130741243f1cf11f8f1c251d8198e92 (patch) | |
| tree | 75c64e6bc39482daccdea4c562796dfa48da4bcb /lib/utils/tests/test-utils.cc | |
| parent | 1f85e9bdb7715a81529e8e6b48c4e20a3a6beb4c (diff) | |
test-utils: fix some clang-tidy warnings
Diffstat (limited to 'lib/utils/tests/test-utils.cc')
| -rw-r--r-- | lib/utils/tests/test-utils.cc | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/utils/tests/test-utils.cc b/lib/utils/tests/test-utils.cc index 0551bdb..195f996 100644 --- a/lib/utils/tests/test-utils.cc +++ b/lib/utils/tests/test-utils.cc @@ -21,21 +21,20 @@ #include <glib.h> #include <iostream> -#include <sstream> #include <functional> #include <array> #include "mu-utils.hh" +#include "mu-utils-file.hh" + #include "mu-test-utils.hh" -#include "mu-error.hh" using namespace Mu; - struct Case { - const std::string expr; - bool is_first{}; - const std::string expected; + std::string expr; + bool is_first{}; + std::string expected; }; using CaseVec = std::vector<Case>; using ProcFunc = std::function<std::string(std::string, bool)>; @@ -62,7 +61,7 @@ test_date_basic() } g_setenv("TZ", hki, TRUE); - std::vector<std::tuple<const char*, bool/*is_first*/, ::time_t>> cases = {{ + const std::vector<std::tuple<const char*, bool/*is_first*/, ::time_t>> cases = {{ {"2015-09-18T09:10:23", true, 1442556623}, {"1972-12-14T09:10:23", true, 93165023}, {"1972-12-14T09:10", true, 93165000}, @@ -88,7 +87,7 @@ test_date_basic() for (auto& test: cases) { if (g_test_verbose()) - g_debug("checking %s", std::get<0>(test)); + mu_debug("checking {}", std::get<0>(test)); g_assert_cmpuint(parse_date_time(std::get<0>(test), std::get<1>(test)).value_or(-1),==, std::get<2>(test)); @@ -96,7 +95,7 @@ test_date_basic() } static void -test_date_ymwdhMs(void) +test_date_ymwdhMs() { struct testcase { std::string expr; @@ -104,7 +103,8 @@ test_date_ymwdhMs(void) int tolerance; }; - std::array<testcase, 7> cases = {{ + + const std::array<testcase, 7> cases = {{ {"7s", 7, 1}, {"3M", 3 * 60, 1}, {"3h", 3 * 60 * 60, 1}, @@ -154,9 +154,8 @@ test_utf8_clean() { assert_equal(utf8_clean("James Holden"), "James Holden"); - const uint8_t invalid_bytes[] ={ 'a' , 0xff, 'c', '\0'}; - std::string invalid{reinterpret_cast<const char*>(invalid_bytes), - sizeof(invalid_bytes) - 1}; + const std::array<char, 3> invalid_bytes ={ 'a' , static_cast<char>(0xff), 'c'}; + std::string invalid{invalid_bytes.data(), invalid_bytes.size()}; g_assert_false(g_utf8_validate(invalid.c_str(), invalid.length(), nullptr)); @@ -311,9 +310,8 @@ test_locale_workaround() g_assert_true(locale_workaround()); } - static void -test_summarize(void) +test_summarize() { const char *txt = "Khiron was fortified and made the seat of a pargana during " |
