mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Place the anonymous namespace within the fmt namespace
for header-only configuration as suggested by Alf Steinbach.
This commit is contained in:
@ -102,6 +102,7 @@ static inline fmt::internal::None<> strerror_s(char *, std::size_t, ...) {
|
|||||||
return fmt::internal::None<>();
|
return fmt::internal::None<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace fmt {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
@ -406,6 +407,7 @@ template <>
|
|||||||
inline Arg::StringValue<wchar_t> ignore_incompatible_str(
|
inline Arg::StringValue<wchar_t> ignore_incompatible_str(
|
||||||
Arg::StringValue<wchar_t> s) { return s; }
|
Arg::StringValue<wchar_t> s) { return s; }
|
||||||
} // namespace
|
} // namespace
|
||||||
|
} // namespace fmt
|
||||||
|
|
||||||
FMT_FUNC void fmt::SystemError::init(
|
FMT_FUNC void fmt::SystemError::init(
|
||||||
int err_code, StringRef format_str, ArgList args) {
|
int err_code, StringRef format_str, ArgList args) {
|
||||||
|
@ -40,7 +40,7 @@ TEST(FormatTest, ArgConverter) {
|
|||||||
Arg arg = Arg();
|
Arg arg = Arg();
|
||||||
arg.type = Arg::LONG_LONG;
|
arg.type = Arg::LONG_LONG;
|
||||||
arg.long_long_value = std::numeric_limits<fmt::LongLong>::max();
|
arg.long_long_value = std::numeric_limits<fmt::LongLong>::max();
|
||||||
ArgConverter<fmt::LongLong>(arg, 'd').visit(arg);
|
fmt::ArgConverter<fmt::LongLong>(arg, 'd').visit(arg);
|
||||||
EXPECT_EQ(Arg::LONG_LONG, arg.type);
|
EXPECT_EQ(Arg::LONG_LONG, arg.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ TEST(FormatTest, StrError) {
|
|||||||
char *message = 0;
|
char *message = 0;
|
||||||
char buffer[BUFFER_SIZE];
|
char buffer[BUFFER_SIZE];
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
EXPECT_DEBUG_DEATH(safe_strerror(EDOM, message = 0, 0), "Assertion");
|
EXPECT_DEBUG_DEATH(fmt::safe_strerror(EDOM, message = 0, 0), "Assertion");
|
||||||
EXPECT_DEBUG_DEATH(safe_strerror(EDOM, message = buffer, 0), "Assertion");
|
EXPECT_DEBUG_DEATH(fmt::safe_strerror(EDOM, message = buffer, 0), "Assertion");
|
||||||
#endif
|
#endif
|
||||||
buffer[0] = 'x';
|
buffer[0] = 'x';
|
||||||
#ifdef _GNU_SOURCE
|
#ifdef _GNU_SOURCE
|
||||||
@ -68,7 +68,7 @@ TEST(FormatTest, StrError) {
|
|||||||
int error_code = EDOM;
|
int error_code = EDOM;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int result = safe_strerror(error_code, message = buffer, BUFFER_SIZE);
|
int result = fmt::safe_strerror(error_code, message = buffer, BUFFER_SIZE);
|
||||||
EXPECT_EQ(0, result);
|
EXPECT_EQ(0, result);
|
||||||
std::size_t message_size = std::strlen(message);
|
std::size_t message_size = std::strlen(message);
|
||||||
EXPECT_GE(BUFFER_SIZE - 1u, message_size);
|
EXPECT_GE(BUFFER_SIZE - 1u, message_size);
|
||||||
@ -76,9 +76,9 @@ TEST(FormatTest, StrError) {
|
|||||||
|
|
||||||
// safe_strerror never uses buffer on MinGW.
|
// safe_strerror never uses buffer on MinGW.
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
result = safe_strerror(error_code, message = buffer, message_size);
|
result = fmt::safe_strerror(error_code, message = buffer, message_size);
|
||||||
EXPECT_EQ(ERANGE, result);
|
EXPECT_EQ(ERANGE, result);
|
||||||
result = safe_strerror(error_code, message = buffer, 1);
|
result = fmt::safe_strerror(error_code, message = buffer, 1);
|
||||||
EXPECT_EQ(buffer, message); // Message should point to buffer.
|
EXPECT_EQ(buffer, message); // Message should point to buffer.
|
||||||
EXPECT_EQ(ERANGE, result);
|
EXPECT_EQ(ERANGE, result);
|
||||||
EXPECT_STREQ("", message);
|
EXPECT_STREQ("", message);
|
||||||
@ -90,21 +90,21 @@ TEST(FormatTest, FormatErrorCode) {
|
|||||||
{
|
{
|
||||||
fmt::MemoryWriter w;
|
fmt::MemoryWriter w;
|
||||||
w << "garbage";
|
w << "garbage";
|
||||||
format_error_code(w, 42, "test");
|
fmt::format_error_code(w, 42, "test");
|
||||||
EXPECT_EQ("test: " + msg, w.str());
|
EXPECT_EQ("test: " + msg, w.str());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
fmt::MemoryWriter w;
|
fmt::MemoryWriter w;
|
||||||
std::string prefix(
|
std::string prefix(
|
||||||
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size() + 1, 'x');
|
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size() + 1, 'x');
|
||||||
format_error_code(w, 42, prefix);
|
fmt::format_error_code(w, 42, prefix);
|
||||||
EXPECT_EQ(msg, w.str());
|
EXPECT_EQ(msg, w.str());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
fmt::MemoryWriter w;
|
fmt::MemoryWriter w;
|
||||||
std::string prefix(
|
std::string prefix(
|
||||||
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size(), 'x');
|
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size(), 'x');
|
||||||
format_error_code(w, 42, prefix);
|
fmt::format_error_code(w, 42, prefix);
|
||||||
EXPECT_EQ(prefix + sep + msg, w.str());
|
EXPECT_EQ(prefix + sep + msg, w.str());
|
||||||
std::size_t size = fmt::internal::INLINE_BUFFER_SIZE;
|
std::size_t size = fmt::internal::INLINE_BUFFER_SIZE;
|
||||||
EXPECT_EQ(size, w.size());
|
EXPECT_EQ(size, w.size());
|
||||||
|
Reference in New Issue
Block a user