Switch to vformat_to

Drive-by: reduce the amount of occurences of #ifdef SPDLOG_USE_STD_FORMAT
This commit is contained in:
Charles Milette
2022-04-21 21:46:58 -04:00
parent b3ce5ed379
commit ebeb3707b1
10 changed files with 66 additions and 166 deletions

View File

@@ -3,17 +3,14 @@
#include "spdlog/details/fmt_helper.h"
using spdlog::memory_buf_t;
using spdlog::details::fmt_helper::to_string_view;
void test_pad2(int n, const char *expected)
{
memory_buf_t buf;
spdlog::details::fmt_helper::pad2(n, buf);
#ifdef SPDLOG_USE_STD_FORMAT
REQUIRE(buf == expected);
#else
REQUIRE(fmt::to_string(buf) == expected);
#endif
REQUIRE(to_string_view(buf) == expected);
}
void test_pad3(uint32_t n, const char *expected)
@@ -21,11 +18,7 @@ void test_pad3(uint32_t n, const char *expected)
memory_buf_t buf;
spdlog::details::fmt_helper::pad3(n, buf);
#ifdef SPDLOG_USE_STD_FORMAT
REQUIRE(buf == expected);
#else
REQUIRE(fmt::to_string(buf) == expected);
#endif
REQUIRE(to_string_view(buf) == expected);
}
void test_pad6(std::size_t n, const char *expected)
@@ -33,11 +26,7 @@ void test_pad6(std::size_t n, const char *expected)
memory_buf_t buf;
spdlog::details::fmt_helper::pad6(n, buf);
#ifdef SPDLOG_USE_STD_FORMAT
REQUIRE(buf == expected);
#else
REQUIRE(fmt::to_string(buf) == expected);
#endif
REQUIRE(to_string_view(buf) == expected);
}
void test_pad9(std::size_t n, const char *expected)
@@ -45,11 +34,7 @@ void test_pad9(std::size_t n, const char *expected)
memory_buf_t buf;
spdlog::details::fmt_helper::pad9(n, buf);
#ifdef SPDLOG_USE_STD_FORMAT
REQUIRE(buf == expected);
#else
REQUIRE(fmt::to_string(buf) == expected);
#endif
REQUIRE(to_string_view(buf) == expected);
}
TEST_CASE("pad2", "[fmt_helper]")