mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 10:31:34 +08:00
Added source_location tests
This commit is contained in:
parent
5ae1ace844
commit
767ef493f7
@ -45,7 +45,8 @@ set(SPDLOG_UTESTS_SOURCES
|
|||||||
test_time_point.cpp
|
test_time_point.cpp
|
||||||
test_stopwatch.cpp
|
test_stopwatch.cpp
|
||||||
test_circular_q.cpp
|
test_circular_q.cpp
|
||||||
test_ringbuffer_sink.cpp)
|
test_ringbuffer_sink.cpp
|
||||||
|
test_source_location.cpp)
|
||||||
|
|
||||||
if(NOT SPDLOG_NO_EXCEPTIONS)
|
if(NOT SPDLOG_NO_EXCEPTIONS)
|
||||||
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
||||||
|
@ -71,7 +71,7 @@ TEST_CASE("flush_error_handler", "[errors]")
|
|||||||
REQUIRE_THROWS_AS(logger->flush(), custom_ex);
|
REQUIRE_THROWS_AS(logger->flush(), custom_ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(SPDLOG_USE_STD_FORMAT)
|
|
||||||
TEST_CASE("async_error_handler", "[errors]")
|
TEST_CASE("async_error_handler", "[errors]")
|
||||||
{
|
{
|
||||||
prepare_logdir();
|
prepare_logdir();
|
||||||
@ -98,7 +98,7 @@ TEST_CASE("async_error_handler", "[errors]")
|
|||||||
require_message_count(SIMPLE_ASYNC_LOG, 2);
|
require_message_count(SIMPLE_ASYNC_LOG, 2);
|
||||||
REQUIRE(file_contents("test_logs/custom_err.txt") == err_msg);
|
REQUIRE(file_contents("test_logs/custom_err.txt") == err_msg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Make sure async error handler is executed
|
// Make sure async error handler is executed
|
||||||
TEST_CASE("async_error_handler2", "[errors]")
|
TEST_CASE("async_error_handler2", "[errors]")
|
||||||
|
21
tests/test_source_location.cpp
Normal file
21
tests/test_source_location.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#define SPDLOG_USE_SOURCE_LOCATION
|
||||||
|
#include "includes.h"
|
||||||
|
#include "test_sink.h"
|
||||||
|
|
||||||
|
#if defined(SPDLOG_STD_SOURCE_LOCATION) || defined(SPDLOG_EXPERIMENTAL_SOURCE_LOCATION)
|
||||||
|
|
||||||
|
using spdlog::details::os::default_eol;
|
||||||
|
|
||||||
|
TEST_CASE("test_source_location", "[source_location]")
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
|
||||||
|
spdlog::logger oss_logger("oss", oss_sink);
|
||||||
|
oss_logger.set_pattern("%s:%# %v");
|
||||||
|
|
||||||
|
oss_logger.info("Hello {}", "source location");
|
||||||
|
REQUIRE(oss.str() == std::string("test_source_location.cpp:16 Hello source location") + default_eol);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user