mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 17:52:05 +08:00
Fix source_loc test
This commit is contained in:
parent
968dcfbc6b
commit
3fc14822ef
@ -1,20 +1,21 @@
|
|||||||
#define SPDLOG_SOURCE_LOCATION
|
#ifndef SPDLOG_NO_SOURCE_LOC
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "spdlog/sinks/ostream_sink.h"
|
#include "spdlog/sinks/ostream_sink.h"
|
||||||
#include "test_sink.h"
|
#include "test_sink.h"
|
||||||
|
|
||||||
#if defined(SPDLOG_HAVE_STD_SOURCE_LOCATION) || defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION)
|
|
||||||
|
|
||||||
using spdlog::details::os::default_eol;
|
using spdlog::details::os::default_eol;
|
||||||
|
|
||||||
TEST_CASE("test_source_location", "[source_location]") {
|
TEST_CASE("test_source_location", "[source_location]") {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
|
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
|
||||||
spdlog::logger oss_logger("oss", oss_sink);
|
auto oss_logger = std::make_shared<spdlog::logger>("oss", oss_sink);
|
||||||
oss_logger.set_pattern("%s:%# %v");
|
//spdlog::logger oss_logger("oss", oss_sink);
|
||||||
|
oss_logger->set_pattern("%s:%# %v");
|
||||||
|
|
||||||
oss_logger.info("Hello {}", "source location");
|
SPDLOG_LOGGER_CALL(oss_logger, spdlog::level::info, "Hello {}", "source location");
|
||||||
REQUIRE(oss.str() == std::string("test_source_location.cpp:16 Hello source location") + default_eol);
|
REQUIRE(oss.str() == std::string("test_source_location.cpp:17 Hello source location") + default_eol);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user