mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 09:09:35 +08:00
Enabled bin_to_hex utest for stdformat, fixed std::formatter (#3315)
* Enabled bin_to_hex utest for stdformat, and fixed std::formatter * fixed usage of \ in macos.yml * explicitly cast diff variable in test_sink * moved from ::iterator to decltype * added fix for custom callbacks --------- Co-authored-by: Jan Koniarik <veverak@Jans-MacBook-Pro.local>
This commit is contained in:
@@ -48,7 +48,8 @@ set(SPDLOG_UTESTS_SOURCES
|
||||
test_cfg.cpp
|
||||
test_time_point.cpp
|
||||
test_stopwatch.cpp
|
||||
test_circular_q.cpp)
|
||||
test_circular_q.cpp
|
||||
test_bin_to_hex.cpp)
|
||||
|
||||
if(NOT SPDLOG_NO_EXCEPTIONS)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
||||
@@ -58,10 +59,6 @@ if(systemd_FOUND)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
|
||||
endif()
|
||||
|
||||
if(NOT SPDLOG_USE_STD_FORMAT)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_bin_to_hex.cpp)
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
|
||||
function(spdlog_prepare_test test_target spdlog_lib)
|
||||
|
@@ -16,7 +16,8 @@ TEST_CASE("custom_callback_logger", "[custom_callback_logger]") {
|
||||
spdlog::memory_buf_t formatted;
|
||||
formatter.format(msg, formatted);
|
||||
auto eol_len = strlen(spdlog::details::os::default_eol);
|
||||
lines.emplace_back(formatted.begin(), formatted.end() - eol_len);
|
||||
using diff_t = typename std::iterator_traits<decltype(formatted.end())>::difference_type;
|
||||
lines.emplace_back(formatted.begin(), formatted.end() - static_cast<diff_t>(eol_len));
|
||||
});
|
||||
std::shared_ptr<spdlog::sinks::test_sink_st> test_sink(new spdlog::sinks::test_sink_st);
|
||||
|
||||
|
@@ -47,8 +47,9 @@ protected:
|
||||
base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||
// save the line without the eol
|
||||
auto eol_len = strlen(details::os::default_eol);
|
||||
using diff_t = typename std::iterator_traits<decltype(formatted.end())>::difference_type;
|
||||
if (lines_.size() < lines_to_save) {
|
||||
lines_.emplace_back(formatted.begin(), formatted.end() - eol_len);
|
||||
lines_.emplace_back(formatted.begin(), formatted.end() - static_cast<diff_t>(eol_len));
|
||||
}
|
||||
msg_counter_++;
|
||||
std::this_thread::sleep_for(delay_);
|
||||
|
Reference in New Issue
Block a user