spdlog/tests/test_time_point.cpp
Gabi Melman 166843ff3a
Some checks failed
linux / ${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }}) (map[asan:ON build_type:Debug … (push) Has been cancelled
linux / ${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }}) (map[build_type:Debug compiler… (push) Has been cancelled
linux / ${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }}) (map[build_type:Release compil… (push) Has been cancelled
macos / macOS Clang (C++17, Release) (push) Has been cancelled
windows / build (map[BUILD_EXAMPLE:OFF BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:17 FATAL_ERRORS:ON GENERATOR:Visual Studio 17 2022]) (push) Has been cancelled
windows / build (map[BUILD_EXAMPLE:OFF BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:20 FATAL_ERRORS:ON GENERATOR:Visual Studio 17 2022]) (push) Has been cancelled
windows / build (map[BUILD_EXAMPLE:ON BUILD_SHARED:OFF BUILD_TYPE:Release CXX_STANDARD:17 FATAL_ERRORS:ON GENERATOR:Visual Studio 17 2022]) (push) Has been cancelled
windows / build_2019 (map[BUILD_EXAMPLE:ON BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:17 FATAL_ERRORS:ON GENERATOR:Visual Studio 16 2019]) (push) Has been cancelled
windows / build_2019 (map[BUILD_EXAMPLE:ON BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:20 FATAL_ERRORS:ON GENERATOR:Visual Studio 16 2019]) (push) Has been cancelled
V2.x no reg (#3285)
Removed registry
2024-12-06 19:21:42 +02:00

35 lines
1.4 KiB
C++

#include "includes.h"
#include "spdlog/async.h"
#include "test_sink.h"
TEST_CASE("time_point1", "[time_point log_msg]") {
std::shared_ptr<spdlog::sinks::test_sink_st> test_sink(new spdlog::sinks::test_sink_st);
spdlog::logger logger("test-time_point", test_sink);
spdlog::source_loc source{};
std::chrono::system_clock::time_point tp{std::chrono::system_clock::now()};
test_sink->set_pattern("%T.%F"); // interested in the time_point
// all the following should have the same time
test_sink->set_delay(std::chrono::milliseconds(10));
for (int i = 0; i < 5; i++) {
spdlog::details::log_msg msg{tp, source, "test_logger", spdlog::level::info, "message"};
test_sink->log(msg);
}
logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(source, spdlog::level::info,
"formatted message"); // last line has different time_point
// now the real test... that the times are the same.
std::vector<std::string> lines = test_sink->lines();
REQUIRE(lines[0] == lines[1]);
REQUIRE(lines[2] == lines[3]);
REQUIRE(lines[4] == lines[5]);
REQUIRE(lines[6] == lines[7]);
REQUIRE(lines[8] != lines[9]);
}