internal -> detail (#1538)
This commit is contained in:
@@ -40,8 +40,8 @@ using testing::StrictMock;
|
||||
#if FMT_USE_CONSTEXPR
|
||||
template <unsigned EXPECTED_PARTS_COUNT, typename Format>
|
||||
void check_prepared_parts_type(Format format) {
|
||||
typedef fmt::internal::compiled_format_base<decltype(format)> provider;
|
||||
typedef fmt::internal::format_part<char>
|
||||
typedef fmt::detail::compiled_format_base<decltype(format)> provider;
|
||||
typedef fmt::detail::format_part<char>
|
||||
expected_parts_type[EXPECTED_PARTS_COUNT];
|
||||
static_assert(std::is_same<typename provider::parts_container,
|
||||
expected_parts_type>::value,
|
||||
@@ -85,11 +85,11 @@ TEST(CompileTest, PassCompileString) {
|
||||
TEST(CompileTest, FormatToArrayOfChars) {
|
||||
char buffer[32] = {0};
|
||||
const auto prepared = fmt::compile<int>("4{}");
|
||||
fmt::format_to(fmt::internal::make_checked(buffer, 32), prepared, 2);
|
||||
fmt::format_to(fmt::detail::make_checked(buffer, 32), prepared, 2);
|
||||
EXPECT_EQ(std::string("42"), buffer);
|
||||
wchar_t wbuffer[32] = {0};
|
||||
const auto wprepared = fmt::compile<int>(L"4{}");
|
||||
fmt::format_to(fmt::internal::make_checked(wbuffer, 32), wprepared, 2);
|
||||
fmt::format_to(fmt::detail::make_checked(wbuffer, 32), wprepared, 2);
|
||||
EXPECT_EQ(std::wstring(L"42"), wbuffer);
|
||||
}
|
||||
|
||||
|
||||
+28
-33
@@ -30,8 +30,8 @@
|
||||
|
||||
using fmt::basic_format_arg;
|
||||
using fmt::string_view;
|
||||
using fmt::internal::buffer;
|
||||
using fmt::internal::value;
|
||||
using fmt::detail::buffer;
|
||||
using fmt::detail::value;
|
||||
|
||||
using testing::_;
|
||||
using testing::StrictMock;
|
||||
@@ -42,7 +42,7 @@ struct test_struct {};
|
||||
|
||||
template <typename Context, typename T>
|
||||
basic_format_arg<Context> make_arg(const T& value) {
|
||||
return fmt::internal::make_arg<Context>(value);
|
||||
return fmt::detail::make_arg<Context>(value);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -148,7 +148,7 @@ TEST(BufferTest, Access) {
|
||||
EXPECT_EQ(11, buffer[0]);
|
||||
buffer[3] = 42;
|
||||
EXPECT_EQ(42, *(&buffer[0] + 3));
|
||||
const fmt::internal::buffer<char>& const_buffer = buffer;
|
||||
const fmt::detail::buffer<char>& const_buffer = buffer;
|
||||
EXPECT_EQ(42, const_buffer[3]);
|
||||
}
|
||||
|
||||
@@ -234,20 +234,20 @@ struct custom_context {
|
||||
|
||||
TEST(ArgTest, MakeValueWithCustomContext) {
|
||||
test_struct t;
|
||||
fmt::internal::value<custom_context> arg(
|
||||
fmt::internal::arg_mapper<custom_context>().map(t));
|
||||
fmt::detail::value<custom_context> arg(
|
||||
fmt::detail::arg_mapper<custom_context>().map(t));
|
||||
custom_context ctx = {false, fmt::format_parse_context("")};
|
||||
arg.custom.format(&t, ctx.parse_context(), ctx);
|
||||
EXPECT_TRUE(ctx.called);
|
||||
}
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
template <typename Char>
|
||||
bool operator==(custom_value<Char> lhs, custom_value<Char> rhs) {
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
// Use a unique result type to make sure that there are no undesirable
|
||||
@@ -372,12 +372,12 @@ TEST(ArgTest, PointerArg) {
|
||||
struct check_custom {
|
||||
test_result operator()(
|
||||
fmt::basic_format_arg<fmt::format_context>::handle h) const {
|
||||
struct test_buffer : fmt::internal::buffer<char> {
|
||||
struct test_buffer : fmt::detail::buffer<char> {
|
||||
char data[10];
|
||||
test_buffer() : fmt::internal::buffer<char>(data, 0, 10) {}
|
||||
test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
|
||||
void grow(size_t) {}
|
||||
} buffer;
|
||||
fmt::internal::buffer<char>& base = buffer;
|
||||
fmt::detail::buffer<char>& base = buffer;
|
||||
fmt::format_parse_context parse_ctx("");
|
||||
fmt::format_context ctx(std::back_inserter(base), fmt::format_args());
|
||||
h.format(parse_ctx, ctx);
|
||||
@@ -470,9 +470,7 @@ TEST(FormatDynArgsTest, NamedStrings) {
|
||||
store.push_back(fmt::arg("a2", std::cref(str)));
|
||||
str[0] = 'X';
|
||||
|
||||
std::string result = fmt::vformat(
|
||||
"{a1} and {a2}",
|
||||
store);
|
||||
std::string result = fmt::vformat("{a1} and {a2}", store);
|
||||
|
||||
EXPECT_EQ("1234567890 and X234567890", result);
|
||||
}
|
||||
@@ -495,9 +493,7 @@ TEST(FormatDynArgsTest, NamedArgByRef) {
|
||||
store.push_back(1.5f);
|
||||
store.push_back(std::cref(a1));
|
||||
|
||||
std::string result = fmt::vformat(
|
||||
"{a1_} and {} and {} and {}",
|
||||
store);
|
||||
std::string result = fmt::vformat("{a1_} and {} and {} and {}", store);
|
||||
|
||||
EXPECT_EQ("42 and abc and 1.5 and 42", result);
|
||||
}
|
||||
@@ -671,20 +667,19 @@ struct derived_from_string_view : fmt::basic_string_view<Char> {};
|
||||
} // namespace
|
||||
|
||||
TYPED_TEST(IsStringTest, IsString) {
|
||||
EXPECT_TRUE(fmt::internal::is_string<TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<const TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<const TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<std::basic_string<TypeParam>>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<const TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<const TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<std::basic_string<TypeParam>>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<fmt::basic_string_view<TypeParam>>::value);
|
||||
EXPECT_TRUE(
|
||||
fmt::internal::is_string<fmt::basic_string_view<TypeParam>>::value);
|
||||
EXPECT_TRUE(
|
||||
fmt::internal::is_string<derived_from_string_view<TypeParam>>::value);
|
||||
using string_view = fmt::internal::std_string_view<TypeParam>;
|
||||
fmt::detail::is_string<derived_from_string_view<TypeParam>>::value);
|
||||
using string_view = fmt::detail::std_string_view<TypeParam>;
|
||||
EXPECT_TRUE(std::is_empty<string_view>::value !=
|
||||
fmt::internal::is_string<string_view>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<my_ns::my_string<TypeParam>>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_string<my_ns::non_string>::value);
|
||||
fmt::detail::is_string<string_view>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<my_ns::my_string<TypeParam>>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_string<my_ns::non_string>::value);
|
||||
}
|
||||
|
||||
TEST(CoreTest, Format) {
|
||||
@@ -708,10 +703,10 @@ TEST(CoreTest, FormatTo) {
|
||||
TEST(CoreTest, ToStringViewForeignStrings) {
|
||||
using namespace my_ns;
|
||||
EXPECT_EQ(to_string_view(my_string<char>("42")), "42");
|
||||
fmt::internal::type type =
|
||||
fmt::internal::mapped_type_constant<my_string<char>,
|
||||
fmt::format_context>::value;
|
||||
EXPECT_EQ(type, fmt::internal::type::string_type);
|
||||
fmt::detail::type type =
|
||||
fmt::detail::mapped_type_constant<my_string<char>,
|
||||
fmt::format_context>::value;
|
||||
EXPECT_EQ(type, fmt::detail::type::string_type);
|
||||
}
|
||||
|
||||
TEST(CoreTest, FormatForeignStrings) {
|
||||
|
||||
+35
-36
@@ -21,9 +21,9 @@
|
||||
|
||||
#undef max
|
||||
|
||||
using fmt::internal::bigint;
|
||||
using fmt::internal::fp;
|
||||
using fmt::internal::max_value;
|
||||
using fmt::detail::bigint;
|
||||
using fmt::detail::fp;
|
||||
using fmt::detail::max_value;
|
||||
|
||||
static_assert(!std::is_copy_constructible<bigint>::value, "");
|
||||
static_assert(!std::is_copy_assignable<bigint>::value, "");
|
||||
@@ -102,7 +102,7 @@ TEST(BigIntTest, Multiply) {
|
||||
}
|
||||
|
||||
TEST(BigIntTest, Accumulator) {
|
||||
fmt::internal::accumulator acc;
|
||||
fmt::detail::accumulator acc;
|
||||
EXPECT_EQ(acc.lower, 0);
|
||||
EXPECT_EQ(acc.upper, 0);
|
||||
acc.upper = 12;
|
||||
@@ -110,7 +110,7 @@ TEST(BigIntTest, Accumulator) {
|
||||
EXPECT_EQ(static_cast<uint32_t>(acc), 34);
|
||||
acc += 56;
|
||||
EXPECT_EQ(acc.lower, 90);
|
||||
acc += fmt::internal::max_value<uint64_t>();
|
||||
acc += fmt::detail::max_value<uint64_t>();
|
||||
EXPECT_EQ(acc.upper, 13);
|
||||
EXPECT_EQ(acc.lower, 89);
|
||||
acc >>= 32;
|
||||
@@ -262,7 +262,7 @@ TEST(FPTest, GetCachedPower) {
|
||||
typedef std::numeric_limits<double> limits;
|
||||
for (auto exp = limits::min_exponent; exp <= limits::max_exponent; ++exp) {
|
||||
int dec_exp = 0;
|
||||
auto fp = fmt::internal::get_cached_power(exp, dec_exp);
|
||||
auto fp = fmt::detail::get_cached_power(exp, dec_exp);
|
||||
EXPECT_LE(exp, fp.e);
|
||||
int dec_exp_step = 8;
|
||||
EXPECT_LE(fp.e, exp + dec_exp_step * log2(10));
|
||||
@@ -271,8 +271,8 @@ TEST(FPTest, GetCachedPower) {
|
||||
}
|
||||
|
||||
TEST(FPTest, GetRoundDirection) {
|
||||
using fmt::internal::get_round_direction;
|
||||
using fmt::internal::round_direction;
|
||||
using fmt::detail::get_round_direction;
|
||||
using fmt::detail::round_direction;
|
||||
EXPECT_EQ(round_direction::down, get_round_direction(100, 50, 0));
|
||||
EXPECT_EQ(round_direction::up, get_round_direction(100, 51, 0));
|
||||
EXPECT_EQ(round_direction::down, get_round_direction(100, 40, 10));
|
||||
@@ -295,9 +295,9 @@ TEST(FPTest, GetRoundDirection) {
|
||||
}
|
||||
|
||||
TEST(FPTest, FixedHandler) {
|
||||
struct handler : fmt::internal::fixed_handler {
|
||||
struct handler : fmt::detail::fixed_handler {
|
||||
char buffer[10];
|
||||
handler(int prec = 0) : fmt::internal::fixed_handler() {
|
||||
handler(int prec = 0) : fmt::detail::fixed_handler() {
|
||||
buf = buffer;
|
||||
precision = prec;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ TEST(FPTest, FixedHandler) {
|
||||
handler().on_digit('0', 100, 99, 0, exp, false);
|
||||
EXPECT_THROW(handler().on_digit('0', 100, 100, 0, exp, false),
|
||||
assertion_failure);
|
||||
namespace digits = fmt::internal::digits;
|
||||
namespace digits = fmt::detail::digits;
|
||||
EXPECT_EQ(handler(1).on_digit('0', 100, 10, 10, exp, false), digits::done);
|
||||
// Check that divisor - error doesn't overflow.
|
||||
EXPECT_EQ(handler(1).on_digit('0', 100, 10, 101, exp, false), digits::error);
|
||||
@@ -318,7 +318,7 @@ TEST(FPTest, FixedHandler) {
|
||||
|
||||
TEST(FPTest, GrisuFormatCompilesWithNonIEEEDouble) {
|
||||
fmt::memory_buffer buf;
|
||||
format_float(0.42, -1, fmt::internal::float_specs(), buf);
|
||||
format_float(0.42, -1, fmt::detail::float_specs(), buf);
|
||||
}
|
||||
|
||||
template <typename T> struct value_extractor {
|
||||
@@ -330,11 +330,11 @@ template <typename T> struct value_extractor {
|
||||
|
||||
#if FMT_USE_INT128
|
||||
// Apple Clang does not define typeid for __int128_t and __uint128_t.
|
||||
FMT_NORETURN T operator()(fmt::internal::int128_t) {
|
||||
FMT_NORETURN T operator()(fmt::detail::int128_t) {
|
||||
throw std::runtime_error("invalid type __int128_t");
|
||||
}
|
||||
|
||||
FMT_NORETURN T operator()(fmt::internal::uint128_t) {
|
||||
FMT_NORETURN T operator()(fmt::detail::uint128_t) {
|
||||
throw std::runtime_error("invalid type __uint128_t");
|
||||
}
|
||||
#endif
|
||||
@@ -342,9 +342,9 @@ template <typename T> struct value_extractor {
|
||||
|
||||
TEST(FormatTest, ArgConverter) {
|
||||
long long value = max_value<long long>();
|
||||
auto arg = fmt::internal::make_arg<fmt::format_context>(value);
|
||||
auto arg = fmt::detail::make_arg<fmt::format_context>(value);
|
||||
fmt::visit_format_arg(
|
||||
fmt::internal::arg_converter<long long, fmt::format_context>(arg, 'd'),
|
||||
fmt::detail::arg_converter<long long, fmt::format_context>(arg, 'd'),
|
||||
arg);
|
||||
EXPECT_EQ(value, fmt::visit_format_arg(value_extractor<long long>(), arg));
|
||||
}
|
||||
@@ -360,9 +360,9 @@ TEST(FormatTest, FormatNegativeNaN) {
|
||||
TEST(FormatTest, StrError) {
|
||||
char* message = nullptr;
|
||||
char buffer[BUFFER_SIZE];
|
||||
EXPECT_ASSERT(fmt::internal::safe_strerror(EDOM, message = nullptr, 0),
|
||||
EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = nullptr, 0),
|
||||
"invalid buffer");
|
||||
EXPECT_ASSERT(fmt::internal::safe_strerror(EDOM, message = buffer, 0),
|
||||
EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = buffer, 0),
|
||||
"invalid buffer");
|
||||
buffer[0] = 'x';
|
||||
#if defined(_GNU_SOURCE) && !defined(__COVERITY__)
|
||||
@@ -374,7 +374,7 @@ TEST(FormatTest, StrError) {
|
||||
#endif
|
||||
|
||||
int result =
|
||||
fmt::internal::safe_strerror(error_code, message = buffer, BUFFER_SIZE);
|
||||
fmt::detail::safe_strerror(error_code, message = buffer, BUFFER_SIZE);
|
||||
EXPECT_EQ(result, 0);
|
||||
size_t message_size = std::strlen(message);
|
||||
EXPECT_GE(BUFFER_SIZE - 1u, message_size);
|
||||
@@ -383,9 +383,9 @@ TEST(FormatTest, StrError) {
|
||||
// safe_strerror never uses buffer on MinGW.
|
||||
#if !defined(__MINGW32__) && !defined(__sun)
|
||||
result =
|
||||
fmt::internal::safe_strerror(error_code, message = buffer, message_size);
|
||||
fmt::detail::safe_strerror(error_code, message = buffer, message_size);
|
||||
EXPECT_EQ(ERANGE, result);
|
||||
result = fmt::internal::safe_strerror(error_code, message = buffer, 1);
|
||||
result = fmt::detail::safe_strerror(error_code, message = buffer, 1);
|
||||
EXPECT_EQ(buffer, message); // Message should point to buffer.
|
||||
EXPECT_EQ(ERANGE, result);
|
||||
EXPECT_STREQ("", message);
|
||||
@@ -397,14 +397,14 @@ TEST(FormatTest, FormatErrorCode) {
|
||||
{
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "garbage");
|
||||
fmt::internal::format_error_code(buffer, 42, "test");
|
||||
fmt::detail::format_error_code(buffer, 42, "test");
|
||||
EXPECT_EQ("test: " + msg, to_string(buffer));
|
||||
}
|
||||
{
|
||||
fmt::memory_buffer buffer;
|
||||
std::string prefix(fmt::inline_buffer_size - msg.size() - sep.size() + 1,
|
||||
'x');
|
||||
fmt::internal::format_error_code(buffer, 42, prefix);
|
||||
fmt::detail::format_error_code(buffer, 42, prefix);
|
||||
EXPECT_EQ(msg, to_string(buffer));
|
||||
}
|
||||
int codes[] = {42, -1};
|
||||
@@ -413,32 +413,32 @@ TEST(FormatTest, FormatErrorCode) {
|
||||
msg = fmt::format("error {}", codes[i]);
|
||||
fmt::memory_buffer buffer;
|
||||
std::string prefix(fmt::inline_buffer_size - msg.size() - sep.size(), 'x');
|
||||
fmt::internal::format_error_code(buffer, codes[i], prefix);
|
||||
fmt::detail::format_error_code(buffer, codes[i], prefix);
|
||||
EXPECT_EQ(prefix + sep + msg, to_string(buffer));
|
||||
size_t size = fmt::inline_buffer_size;
|
||||
EXPECT_EQ(size, buffer.size());
|
||||
buffer.resize(0);
|
||||
// Test with a message that doesn't fit into the buffer.
|
||||
prefix += 'x';
|
||||
fmt::internal::format_error_code(buffer, codes[i], prefix);
|
||||
fmt::detail::format_error_code(buffer, codes[i], prefix);
|
||||
EXPECT_EQ(msg, to_string(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(FormatTest, CountCodePoints) {
|
||||
EXPECT_EQ(
|
||||
4, fmt::internal::count_code_points(
|
||||
fmt::basic_string_view<fmt::internal::char8_type>(
|
||||
reinterpret_cast<const fmt::internal::char8_type*>("ёжик"))));
|
||||
EXPECT_EQ(4,
|
||||
fmt::detail::count_code_points(
|
||||
fmt::basic_string_view<fmt::detail::char8_type>(
|
||||
reinterpret_cast<const fmt::detail::char8_type*>("ёжик"))));
|
||||
}
|
||||
|
||||
// Tests fmt::internal::count_digits for integer type Int.
|
||||
// Tests fmt::detail::count_digits for integer type Int.
|
||||
template <typename Int> void test_count_digits() {
|
||||
for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::internal::count_digits(i));
|
||||
for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::detail::count_digits(i));
|
||||
for (Int i = 1, n = 1, end = max_value<Int>() / 10; n <= end; ++i) {
|
||||
n *= 10;
|
||||
EXPECT_EQ(i, fmt::internal::count_digits(n - 1));
|
||||
EXPECT_EQ(i + 1, fmt::internal::count_digits(n));
|
||||
EXPECT_EQ(i, fmt::detail::count_digits(n - 1));
|
||||
EXPECT_EQ(i + 1, fmt::detail::count_digits(n));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,9 +449,8 @@ TEST(UtilTest, CountDigits) {
|
||||
|
||||
TEST(UtilTest, WriteFallbackUIntPtr) {
|
||||
std::string s;
|
||||
fmt::internal::write_ptr<char>(
|
||||
fmt::detail::write_ptr<char>(
|
||||
std::back_inserter(s),
|
||||
fmt::internal::fallback_uintptr(reinterpret_cast<void*>(0xface)),
|
||||
nullptr);
|
||||
fmt::detail::fallback_uintptr(reinterpret_cast<void*>(0xface)), nullptr);
|
||||
EXPECT_EQ(s, "0xface");
|
||||
}
|
||||
|
||||
+65
-66
@@ -43,7 +43,7 @@ using fmt::memory_buffer;
|
||||
using fmt::string_view;
|
||||
using fmt::wmemory_buffer;
|
||||
using fmt::wstring_view;
|
||||
using fmt::internal::max_value;
|
||||
using fmt::detail::max_value;
|
||||
|
||||
using testing::Return;
|
||||
using testing::StrictMock;
|
||||
@@ -104,10 +104,10 @@ struct uint32_pair {
|
||||
};
|
||||
|
||||
TEST(UtilTest, BitCast) {
|
||||
auto s = fmt::internal::bit_cast<uint32_pair>(uint64_t{42});
|
||||
EXPECT_EQ(fmt::internal::bit_cast<uint64_t>(s), 42ull);
|
||||
s = fmt::internal::bit_cast<uint32_pair>(uint64_t(~0ull));
|
||||
EXPECT_EQ(fmt::internal::bit_cast<uint64_t>(s), ~0ull);
|
||||
auto s = fmt::detail::bit_cast<uint32_pair>(uint64_t{42});
|
||||
EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), 42ull);
|
||||
s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
|
||||
EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), ~0ull);
|
||||
}
|
||||
|
||||
TEST(UtilTest, Increment) {
|
||||
@@ -132,18 +132,18 @@ TEST(UtilTest, ParseNonnegativeInt) {
|
||||
fmt::string_view s = "10000000000";
|
||||
auto begin = s.begin(), end = s.end();
|
||||
EXPECT_THROW_MSG(
|
||||
parse_nonnegative_int(begin, end, fmt::internal::error_handler()),
|
||||
parse_nonnegative_int(begin, end, fmt::detail::error_handler()),
|
||||
fmt::format_error, "number is too big");
|
||||
s = "2147483649";
|
||||
begin = s.begin();
|
||||
end = s.end();
|
||||
EXPECT_THROW_MSG(
|
||||
parse_nonnegative_int(begin, end, fmt::internal::error_handler()),
|
||||
parse_nonnegative_int(begin, end, fmt::detail::error_handler()),
|
||||
fmt::format_error, "number is too big");
|
||||
}
|
||||
|
||||
TEST(IteratorTest, CountingIterator) {
|
||||
fmt::internal::counting_iterator it;
|
||||
fmt::detail::counting_iterator it;
|
||||
auto prev = it++;
|
||||
EXPECT_EQ(prev.count(), 0);
|
||||
EXPECT_EQ(it.count(), 1);
|
||||
@@ -151,7 +151,7 @@ TEST(IteratorTest, CountingIterator) {
|
||||
|
||||
TEST(IteratorTest, TruncatingIterator) {
|
||||
char* p = nullptr;
|
||||
fmt::internal::truncating_iterator<char*> it(p, 3);
|
||||
fmt::detail::truncating_iterator<char*> it(p, 3);
|
||||
auto prev = it++;
|
||||
EXPECT_EQ(prev.base(), p);
|
||||
EXPECT_EQ(it.base(), p + 1);
|
||||
@@ -160,7 +160,7 @@ TEST(IteratorTest, TruncatingIterator) {
|
||||
TEST(IteratorTest, TruncatingBackInserter) {
|
||||
std::string buffer;
|
||||
auto bi = std::back_inserter(buffer);
|
||||
fmt::internal::truncating_iterator<decltype(bi)> it(bi, 2);
|
||||
fmt::detail::truncating_iterator<decltype(bi)> it(bi, 2);
|
||||
*it++ = '4';
|
||||
*it++ = '2';
|
||||
*it++ = '1';
|
||||
@@ -169,20 +169,20 @@ TEST(IteratorTest, TruncatingBackInserter) {
|
||||
}
|
||||
|
||||
TEST(IteratorTest, IsOutputIterator) {
|
||||
EXPECT_TRUE(fmt::internal::is_output_iterator<char*>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<const char*>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<std::string>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_output_iterator<
|
||||
EXPECT_TRUE(fmt::detail::is_output_iterator<char*>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<const char*>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<std::string>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_output_iterator<
|
||||
std::back_insert_iterator<std::string>>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_output_iterator<std::string::iterator>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_output_iterator<std::string::iterator>::value);
|
||||
EXPECT_FALSE(
|
||||
fmt::internal::is_output_iterator<std::string::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<std::list<char>>::value);
|
||||
fmt::detail::is_output_iterator<std::string::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<std::list<char>>::value);
|
||||
EXPECT_TRUE(
|
||||
fmt::internal::is_output_iterator<std::list<char>::iterator>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<
|
||||
std::list<char>::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<uint32_pair>::value);
|
||||
fmt::detail::is_output_iterator<std::list<char>::iterator>::value);
|
||||
EXPECT_FALSE(
|
||||
fmt::detail::is_output_iterator<std::list<char>::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<uint32_pair>::value);
|
||||
}
|
||||
|
||||
TEST(MemoryBufferTest, Ctor) {
|
||||
@@ -300,7 +300,7 @@ TEST(MemoryBufferTest, Grow) {
|
||||
void grow(size_t size) { Base::grow(size); }
|
||||
} buffer((Allocator(&alloc)));
|
||||
buffer.resize(7);
|
||||
using fmt::internal::to_unsigned;
|
||||
using fmt::detail::to_unsigned;
|
||||
for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i;
|
||||
EXPECT_EQ(10u, buffer.capacity());
|
||||
int mem[20];
|
||||
@@ -357,21 +357,21 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) {
|
||||
}
|
||||
|
||||
TEST(UtilTest, UTF8ToUTF16) {
|
||||
fmt::internal::utf8_to_utf16 u("лошадка");
|
||||
fmt::detail::utf8_to_utf16 u("лошадка");
|
||||
EXPECT_EQ(L"\x043B\x043E\x0448\x0430\x0434\x043A\x0430", u.str());
|
||||
EXPECT_EQ(7, u.size());
|
||||
// U+10437 { DESERET SMALL LETTER YEE }
|
||||
EXPECT_EQ(L"\xD801\xDC37", fmt::internal::utf8_to_utf16("𐐷").str());
|
||||
EXPECT_THROW_MSG(fmt::internal::utf8_to_utf16("\xc3\x28"), std::runtime_error,
|
||||
EXPECT_EQ(L"\xD801\xDC37", fmt::detail::utf8_to_utf16("𐐷").str());
|
||||
EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16("\xc3\x28"), std::runtime_error,
|
||||
"invalid utf8");
|
||||
EXPECT_THROW_MSG(fmt::internal::utf8_to_utf16(fmt::string_view("л", 1)),
|
||||
EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16(fmt::string_view("л", 1)),
|
||||
std::runtime_error, "invalid utf8");
|
||||
EXPECT_EQ(L"123456", fmt::internal::utf8_to_utf16("123456").str());
|
||||
EXPECT_EQ(L"123456", fmt::detail::utf8_to_utf16("123456").str());
|
||||
}
|
||||
|
||||
TEST(UtilTest, UTF8ToUTF16EmptyString) {
|
||||
std::string s = "";
|
||||
fmt::internal::utf8_to_utf16 u(s.c_str());
|
||||
fmt::detail::utf8_to_utf16 u(s.c_str());
|
||||
EXPECT_EQ(L"", u.str());
|
||||
EXPECT_EQ(s.size(), u.size());
|
||||
}
|
||||
@@ -534,7 +534,7 @@ TEST(FormatterTest, ManyArgs) {
|
||||
"argument not found");
|
||||
EXPECT_THROW_MSG(TestFormat<21>::format("{21}"), format_error,
|
||||
"argument not found");
|
||||
enum { max_packed_args = fmt::internal::max_packed_args };
|
||||
enum { max_packed_args = fmt::detail::max_packed_args };
|
||||
std::string format_str = fmt::format("{{{}}}", max_packed_args + 1);
|
||||
EXPECT_THROW_MSG(TestFormat<max_packed_args>::format(format_str),
|
||||
format_error, "argument not found");
|
||||
@@ -961,7 +961,7 @@ TEST(FormatterTest, Precision) {
|
||||
EXPECT_THROW_MSG(format("{0:.2f}", reinterpret_cast<void*>(0xcafe)),
|
||||
format_error,
|
||||
"precision not allowed for this argument type");
|
||||
EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::internal::max_value<int>()),
|
||||
EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::detail::max_value<int>()),
|
||||
format_error, "number is too big");
|
||||
|
||||
EXPECT_EQ("st", format("{0:.2}", "str"));
|
||||
@@ -1510,7 +1510,7 @@ TEST(FormatterTest, CustomFormat) {
|
||||
TEST(FormatterTest, CustomFormatTo) {
|
||||
char buf[10] = {};
|
||||
auto end =
|
||||
&*fmt::format_to(fmt::internal::make_checked(buf, 10), "{}", Answer());
|
||||
&*fmt::format_to(fmt::detail::make_checked(buf, 10), "{}", Answer());
|
||||
EXPECT_EQ(end, buf + 2);
|
||||
EXPECT_STREQ(buf, "42");
|
||||
}
|
||||
@@ -1620,7 +1620,7 @@ TEST(FormatTest, Print) {
|
||||
"Don't panic!");
|
||||
#endif
|
||||
// Check that the wide print overload compiles.
|
||||
if (fmt::internal::const_check(false)) fmt::print(L"test");
|
||||
if (fmt::detail::const_check(false)) fmt::print(L"test");
|
||||
}
|
||||
|
||||
TEST(FormatTest, Variadic) {
|
||||
@@ -1631,9 +1631,9 @@ TEST(FormatTest, Variadic) {
|
||||
TEST(FormatTest, Dynamic) {
|
||||
typedef fmt::format_context ctx;
|
||||
std::vector<fmt::basic_format_arg<ctx>> args;
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(42));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>("abc1"));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(1.5f));
|
||||
args.emplace_back(fmt::detail::make_arg<ctx>(42));
|
||||
args.emplace_back(fmt::detail::make_arg<ctx>("abc1"));
|
||||
args.emplace_back(fmt::detail::make_arg<ctx>(1.5f));
|
||||
|
||||
std::string result = fmt::vformat(
|
||||
"{} and {} and {}",
|
||||
@@ -1808,7 +1808,7 @@ TEST(FormatTest, StrongEnum) {
|
||||
using buffer_range = fmt::buffer_range<char>;
|
||||
|
||||
class mock_arg_formatter
|
||||
: public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
: public fmt::detail::arg_formatter_base<buffer_range> {
|
||||
private:
|
||||
#if FMT_USE_INT128
|
||||
MOCK_METHOD1(call, void(__int128_t value));
|
||||
@@ -1817,24 +1817,24 @@ class mock_arg_formatter
|
||||
#endif
|
||||
|
||||
public:
|
||||
typedef fmt::internal::arg_formatter_base<buffer_range> base;
|
||||
typedef fmt::detail::arg_formatter_base<buffer_range> base;
|
||||
typedef buffer_range range;
|
||||
|
||||
mock_arg_formatter(fmt::format_context& ctx, fmt::format_parse_context*,
|
||||
fmt::format_specs* s = nullptr)
|
||||
: base(fmt::internal::get_container(ctx.out()), s, ctx.locale()) {
|
||||
: base(fmt::detail::get_container(ctx.out()), s, ctx.locale()) {
|
||||
EXPECT_CALL(*this, call(42));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<fmt::internal::is_integral<T>::value, iterator>::type
|
||||
typename std::enable_if<fmt::detail::is_integral<T>::value, iterator>::type
|
||||
operator()(T value) {
|
||||
call(value);
|
||||
return base::operator()(value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<!fmt::internal::is_integral<T>::value, iterator>::type
|
||||
typename std::enable_if<!fmt::detail::is_integral<T>::value, iterator>::type
|
||||
operator()(T value) {
|
||||
return base::operator()(value);
|
||||
}
|
||||
@@ -2020,7 +2020,7 @@ struct test_arg_id_handler {
|
||||
template <size_t N>
|
||||
FMT_CONSTEXPR test_arg_id_handler parse_arg_id(const char (&s)[N]) {
|
||||
test_arg_id_handler h;
|
||||
fmt::internal::parse_arg_id(s, s + N, h);
|
||||
fmt::detail::parse_arg_id(s, s + N, h);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -2041,9 +2041,9 @@ struct test_format_specs_handler {
|
||||
fmt::align_t align = fmt::align::none;
|
||||
char fill = 0;
|
||||
int width = 0;
|
||||
fmt::internal::arg_ref<char> width_ref;
|
||||
fmt::detail::arg_ref<char> width_ref;
|
||||
int precision = 0;
|
||||
fmt::internal::arg_ref<char> precision_ref;
|
||||
fmt::detail::arg_ref<char> precision_ref;
|
||||
char type = 0;
|
||||
|
||||
// Workaround for MSVC2017 bug that results in "expression did not evaluate
|
||||
@@ -2069,12 +2069,12 @@ struct test_format_specs_handler {
|
||||
FMT_CONSTEXPR void on_zero() { res = ZERO; }
|
||||
|
||||
FMT_CONSTEXPR void on_width(int w) { width = w; }
|
||||
FMT_CONSTEXPR void on_dynamic_width(fmt::internal::auto_id) {}
|
||||
FMT_CONSTEXPR void on_dynamic_width(fmt::detail::auto_id) {}
|
||||
FMT_CONSTEXPR void on_dynamic_width(int index) { width_ref = index; }
|
||||
FMT_CONSTEXPR void on_dynamic_width(string_view) {}
|
||||
|
||||
FMT_CONSTEXPR void on_precision(int p) { precision = p; }
|
||||
FMT_CONSTEXPR void on_dynamic_precision(fmt::internal::auto_id) {}
|
||||
FMT_CONSTEXPR void on_dynamic_precision(fmt::detail::auto_id) {}
|
||||
FMT_CONSTEXPR void on_dynamic_precision(int index) { precision_ref = index; }
|
||||
FMT_CONSTEXPR void on_dynamic_precision(string_view) {}
|
||||
|
||||
@@ -2086,7 +2086,7 @@ struct test_format_specs_handler {
|
||||
template <size_t N>
|
||||
FMT_CONSTEXPR test_format_specs_handler parse_test_specs(const char (&s)[N]) {
|
||||
test_format_specs_handler h;
|
||||
fmt::internal::parse_format_specs(s, s + N, h);
|
||||
fmt::detail::parse_format_specs(s, s + N, h);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -2130,7 +2130,7 @@ struct test_context {
|
||||
|
||||
template <typename Id>
|
||||
FMT_CONSTEXPR fmt::basic_format_arg<test_context> arg(Id id) {
|
||||
return fmt::internal::make_arg<test_context>(id);
|
||||
return fmt::detail::make_arg<test_context>(id);
|
||||
}
|
||||
|
||||
void on_error(const char*) {}
|
||||
@@ -2143,7 +2143,7 @@ FMT_CONSTEXPR fmt::format_specs parse_specs(const char (&s)[N]) {
|
||||
auto specs = fmt::format_specs();
|
||||
auto parse_ctx = test_parse_context();
|
||||
auto ctx = test_context();
|
||||
fmt::internal::specs_handler<test_parse_context, test_context> h(
|
||||
fmt::detail::specs_handler<test_parse_context, test_context> h(
|
||||
specs, parse_ctx, ctx);
|
||||
parse_format_specs(s, s + N, h);
|
||||
return specs;
|
||||
@@ -2167,11 +2167,11 @@ TEST(FormatTest, ConstexprSpecsHandler) {
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
FMT_CONSTEXPR fmt::internal::dynamic_format_specs<char> parse_dynamic_specs(
|
||||
FMT_CONSTEXPR fmt::detail::dynamic_format_specs<char> parse_dynamic_specs(
|
||||
const char (&s)[N]) {
|
||||
fmt::internal::dynamic_format_specs<char> specs;
|
||||
fmt::detail::dynamic_format_specs<char> specs;
|
||||
test_parse_context ctx{};
|
||||
fmt::internal::dynamic_specs_handler<test_parse_context> h(specs, ctx);
|
||||
fmt::detail::dynamic_specs_handler<test_parse_context> h(specs, ctx);
|
||||
parse_format_specs(s, s + N, h);
|
||||
return specs;
|
||||
}
|
||||
@@ -2195,8 +2195,8 @@ TEST(FormatTest, ConstexprDynamicSpecsHandler) {
|
||||
|
||||
template <size_t N>
|
||||
FMT_CONSTEXPR test_format_specs_handler check_specs(const char (&s)[N]) {
|
||||
fmt::internal::specs_checker<test_format_specs_handler> checker(
|
||||
test_format_specs_handler(), fmt::internal::type::double_type);
|
||||
fmt::detail::specs_checker<test_format_specs_handler> checker(
|
||||
test_format_specs_handler(), fmt::detail::type::double_type);
|
||||
parse_format_specs(s, s + N, checker);
|
||||
return checker;
|
||||
}
|
||||
@@ -2238,7 +2238,7 @@ struct test_format_string_handler {
|
||||
|
||||
template <size_t N> FMT_CONSTEXPR bool parse_string(const char (&s)[N]) {
|
||||
test_format_string_handler h;
|
||||
fmt::internal::parse_format_string<true>(fmt::string_view(s, N - 1), h);
|
||||
fmt::detail::parse_format_string<true>(fmt::string_view(s, N - 1), h);
|
||||
return !h.error;
|
||||
}
|
||||
|
||||
@@ -2283,9 +2283,9 @@ template <typename... Args>
|
||||
FMT_CONSTEXPR bool test_error(const char* fmt, const char* expected_error) {
|
||||
const char* actual_error = nullptr;
|
||||
string_view s(fmt, len(fmt));
|
||||
fmt::internal::format_string_checker<char, test_error_handler, Args...>
|
||||
checker(s, test_error_handler(actual_error));
|
||||
fmt::internal::parse_format_string<true>(s, checker);
|
||||
fmt::detail::format_string_checker<char, test_error_handler, Args...> checker(
|
||||
s, test_error_handler(actual_error));
|
||||
fmt::detail::parse_format_string<true>(s, checker);
|
||||
return equal(actual_error, expected_error);
|
||||
}
|
||||
|
||||
@@ -2299,7 +2299,7 @@ TEST(FormatTest, FormatStringErrors) {
|
||||
EXPECT_ERROR_NOARGS("}", "unmatched '}' in format string");
|
||||
EXPECT_ERROR("{0:s", "unknown format specifier", Date);
|
||||
# if !FMT_MSC_VER || FMT_MSC_VER >= 1916
|
||||
// This causes an internal compiler error in MSVC2017.
|
||||
// This causes an detail compiler error in MSVC2017.
|
||||
EXPECT_ERROR("{:{<}", "invalid fill character '{'", int);
|
||||
EXPECT_ERROR("{:10000000000}", "number is too big", int);
|
||||
EXPECT_ERROR("{:.10000000000}", "number is too big", int);
|
||||
@@ -2358,7 +2358,7 @@ TEST(FormatTest, FormatStringErrors) {
|
||||
|
||||
TEST(FormatTest, VFormatTo) {
|
||||
typedef fmt::format_context context;
|
||||
fmt::basic_format_arg<context> arg = fmt::internal::make_arg<context>(42);
|
||||
fmt::basic_format_arg<context> arg = fmt::detail::make_arg<context>(42);
|
||||
fmt::basic_format_args<context> args(&arg, 1);
|
||||
std::string s;
|
||||
fmt::vformat_to(std::back_inserter(s), "{}", args);
|
||||
@@ -2368,7 +2368,7 @@ TEST(FormatTest, VFormatTo) {
|
||||
EXPECT_EQ("42", s);
|
||||
|
||||
typedef fmt::wformat_context wcontext;
|
||||
fmt::basic_format_arg<wcontext> warg = fmt::internal::make_arg<wcontext>(42);
|
||||
fmt::basic_format_arg<wcontext> warg = fmt::detail::make_arg<wcontext>(42);
|
||||
fmt::basic_format_args<wcontext> wargs(&warg, 1);
|
||||
std::wstring w;
|
||||
fmt::vformat_to(std::back_inserter(w), L"{}", wargs);
|
||||
@@ -2396,7 +2396,7 @@ TEST(FormatTest, EmphasisNonHeaderOnly) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, CharTraitsIsNotAmbiguous) {
|
||||
// Test that we don't inject internal names into the std namespace.
|
||||
// Test that we don't inject detail names into the std namespace.
|
||||
using namespace std;
|
||||
char_traits<char>::char_type c;
|
||||
(void)c;
|
||||
@@ -2434,13 +2434,12 @@ template <typename S> std::string from_u8str(const S& str) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, FormatUTF8Precision) {
|
||||
using str_type = std::basic_string<fmt::internal::char8_type>;
|
||||
str_type format(
|
||||
reinterpret_cast<const fmt::internal::char8_type*>(u8"{:.4}"));
|
||||
str_type str(reinterpret_cast<const fmt::internal::char8_type*>(
|
||||
using str_type = std::basic_string<fmt::detail::char8_type>;
|
||||
str_type format(reinterpret_cast<const fmt::detail::char8_type*>(u8"{:.4}"));
|
||||
str_type str(reinterpret_cast<const fmt::detail::char8_type*>(
|
||||
u8"caf\u00e9s")); // cafés
|
||||
auto result = fmt::format(format, str);
|
||||
EXPECT_EQ(fmt::internal::count_code_points(result), 4);
|
||||
EXPECT_EQ(fmt::detail::count_code_points(result), 4);
|
||||
EXPECT_EQ(result.size(), 5);
|
||||
EXPECT_EQ(from_u8str(result), from_u8str(str.substr(0, 5)));
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "gmock.h"
|
||||
|
||||
using fmt::internal::max_value;
|
||||
using fmt::detail::max_value;
|
||||
|
||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
template <typename Char> struct numpunct : std::numpunct<Char> {
|
||||
|
||||
+15
-16
@@ -27,14 +27,14 @@ using fmt::error_code;
|
||||
|
||||
TEST(UtilTest, UTF16ToUTF8) {
|
||||
std::string s = "ёжик";
|
||||
fmt::internal::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A");
|
||||
fmt::detail::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A");
|
||||
EXPECT_EQ(s, u.str());
|
||||
EXPECT_EQ(s.size(), u.size());
|
||||
}
|
||||
|
||||
TEST(UtilTest, UTF16ToUTF8EmptyString) {
|
||||
std::string s = "";
|
||||
fmt::internal::utf16_to_utf8 u(L"");
|
||||
fmt::detail::utf16_to_utf8 u(L"");
|
||||
EXPECT_EQ(s, u.str());
|
||||
EXPECT_EQ(s.size(), u.size());
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void check_utf_conversion_error(
|
||||
const char* message,
|
||||
fmt::basic_string_view<Char> str = fmt::basic_string_view<Char>(0, 1)) {
|
||||
fmt::memory_buffer out;
|
||||
fmt::internal::format_windows_error(out, ERROR_INVALID_PARAMETER, message);
|
||||
fmt::detail::format_windows_error(out, ERROR_INVALID_PARAMETER, message);
|
||||
fmt::system_error error(0, "");
|
||||
try {
|
||||
(Converter)(str);
|
||||
@@ -56,12 +56,12 @@ void check_utf_conversion_error(
|
||||
}
|
||||
|
||||
TEST(UtilTest, UTF16ToUTF8Error) {
|
||||
check_utf_conversion_error<fmt::internal::utf16_to_utf8, wchar_t>(
|
||||
check_utf_conversion_error<fmt::detail::utf16_to_utf8, wchar_t>(
|
||||
"cannot convert string from UTF-16 to UTF-8");
|
||||
}
|
||||
|
||||
TEST(UtilTest, UTF16ToUTF8Convert) {
|
||||
fmt::internal::utf16_to_utf8 u;
|
||||
fmt::detail::utf16_to_utf8 u;
|
||||
EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::wstring_view(0, 1)));
|
||||
EXPECT_EQ(ERROR_INVALID_PARAMETER,
|
||||
u.convert(fmt::wstring_view(L"foo", INT_MAX + 1u)));
|
||||
@@ -74,17 +74,16 @@ TEST(UtilTest, FormatWindowsError) {
|
||||
0, ERROR_FILE_EXISTS,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
reinterpret_cast<LPWSTR>(&message), 0, 0);
|
||||
fmt::internal::utf16_to_utf8 utf8_message(message);
|
||||
fmt::detail::utf16_to_utf8 utf8_message(message);
|
||||
LocalFree(message);
|
||||
fmt::memory_buffer actual_message;
|
||||
fmt::internal::format_windows_error(actual_message, ERROR_FILE_EXISTS,
|
||||
"test");
|
||||
fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, "test");
|
||||
EXPECT_EQ(fmt::format("test: {}", utf8_message.str()),
|
||||
fmt::to_string(actual_message));
|
||||
actual_message.resize(0);
|
||||
auto max_size = fmt::internal::max_value<size_t>();
|
||||
fmt::internal::format_windows_error(actual_message, ERROR_FILE_EXISTS,
|
||||
fmt::string_view(0, max_size));
|
||||
auto max_size = fmt::detail::max_value<size_t>();
|
||||
fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS,
|
||||
fmt::string_view(0, max_size));
|
||||
EXPECT_EQ(fmt::format("error {}", ERROR_FILE_EXISTS),
|
||||
fmt::to_string(actual_message));
|
||||
}
|
||||
@@ -104,11 +103,11 @@ TEST(UtilTest, FormatLongWindowsError) {
|
||||
reinterpret_cast<LPWSTR>(&message), 0, 0) == 0) {
|
||||
return;
|
||||
}
|
||||
fmt::internal::utf16_to_utf8 utf8_message(message);
|
||||
fmt::detail::utf16_to_utf8 utf8_message(message);
|
||||
LocalFree(message);
|
||||
fmt::memory_buffer actual_message;
|
||||
fmt::internal::format_windows_error(actual_message, provisioning_not_allowed,
|
||||
"test");
|
||||
fmt::detail::format_windows_error(actual_message, provisioning_not_allowed,
|
||||
"test");
|
||||
EXPECT_EQ(fmt::format("test: {}", utf8_message.str()),
|
||||
fmt::to_string(actual_message));
|
||||
}
|
||||
@@ -121,14 +120,14 @@ TEST(UtilTest, WindowsError) {
|
||||
error = e;
|
||||
}
|
||||
fmt::memory_buffer message;
|
||||
fmt::internal::format_windows_error(message, ERROR_FILE_EXISTS, "test error");
|
||||
fmt::detail::format_windows_error(message, ERROR_FILE_EXISTS, "test error");
|
||||
EXPECT_EQ(to_string(message), error.what());
|
||||
EXPECT_EQ(ERROR_FILE_EXISTS, error.error_code());
|
||||
}
|
||||
|
||||
TEST(UtilTest, ReportWindowsError) {
|
||||
fmt::memory_buffer out;
|
||||
fmt::internal::format_windows_error(out, ERROR_FILE_EXISTS, "test error");
|
||||
fmt::detail::format_windows_error(out, ERROR_FILE_EXISTS, "test error");
|
||||
out.push_back('\n');
|
||||
EXPECT_WRITE(stderr,
|
||||
fmt::report_windows_error(ERROR_FILE_EXISTS, "test error"),
|
||||
|
||||
+10
-10
@@ -74,12 +74,12 @@ struct test_arg_formatter : fmt::arg_formatter<range> {
|
||||
|
||||
TEST(OStreamTest, CustomArg) {
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::internal::buffer<char>& base = buffer;
|
||||
fmt::detail::buffer<char>& base = buffer;
|
||||
fmt::format_context ctx(std::back_inserter(base), fmt::format_args());
|
||||
fmt::format_specs spec;
|
||||
test_arg_formatter af(ctx, spec);
|
||||
fmt::visit_format_arg(
|
||||
af, fmt::internal::make_arg<fmt::format_context>(streamable_enum()));
|
||||
af, fmt::detail::make_arg<fmt::format_context>(streamable_enum()));
|
||||
EXPECT_EQ("streamable_enum", std::string(buffer.data(), buffer.size()));
|
||||
}
|
||||
|
||||
@@ -140,16 +140,16 @@ TEST(OStreamTest, WriteToOStream) {
|
||||
fmt::memory_buffer buffer;
|
||||
const char* foo = "foo";
|
||||
buffer.append(foo, foo + std::strlen(foo));
|
||||
fmt::internal::write(os, buffer);
|
||||
fmt::detail::write(os, buffer);
|
||||
EXPECT_EQ("foo", os.str());
|
||||
}
|
||||
|
||||
TEST(OStreamTest, WriteToOStreamMaxSize) {
|
||||
size_t max_size = fmt::internal::max_value<size_t>();
|
||||
std::streamsize max_streamsize = fmt::internal::max_value<std::streamsize>();
|
||||
if (max_size <= fmt::internal::to_unsigned(max_streamsize)) return;
|
||||
size_t max_size = fmt::detail::max_value<size_t>();
|
||||
std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>();
|
||||
if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;
|
||||
|
||||
struct test_buffer : fmt::internal::buffer<char> {
|
||||
struct test_buffer : fmt::detail::buffer<char> {
|
||||
explicit test_buffer(size_t size) { resize(size); }
|
||||
void grow(size_t) {}
|
||||
} buffer(max_size);
|
||||
@@ -171,13 +171,13 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
|
||||
typedef std::make_unsigned<std::streamsize>::type ustreamsize;
|
||||
ustreamsize size = max_size;
|
||||
do {
|
||||
auto n = std::min(size, fmt::internal::to_unsigned(max_streamsize));
|
||||
auto n = std::min(size, fmt::detail::to_unsigned(max_streamsize));
|
||||
EXPECT_CALL(streambuf, xsputn(data, static_cast<std::streamsize>(n)))
|
||||
.WillOnce(testing::Return(max_streamsize));
|
||||
data += n;
|
||||
size -= n;
|
||||
} while (size != 0);
|
||||
fmt::internal::write(os, buffer);
|
||||
fmt::detail::write(os, buffer);
|
||||
}
|
||||
|
||||
TEST(OStreamTest, Join) {
|
||||
@@ -275,7 +275,7 @@ TEST(OStreamTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
|
||||
#ifdef FMT_USE_STRING_VIEW
|
||||
struct explicitly_convertible_to_std_string_view {
|
||||
explicit operator fmt::internal::std_string_view<char>() const {
|
||||
explicit operator fmt::detail::std_string_view<char>() const {
|
||||
return {"foo", 3u};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -261,8 +261,8 @@ TEST(FileTest, Size) {
|
||||
EXPECT_EQ(content.size(), static_cast<unsigned long long>(f.size()));
|
||||
# ifdef _WIN32
|
||||
fmt::memory_buffer message;
|
||||
fmt::internal::format_windows_error(message, ERROR_ACCESS_DENIED,
|
||||
"cannot get file size");
|
||||
fmt::detail::format_windows_error(message, ERROR_ACCESS_DENIED,
|
||||
"cannot get file size");
|
||||
fstat_sim = ERROR;
|
||||
EXPECT_THROW_MSG(f.size(), fmt::windows_error, fmt::to_string(message));
|
||||
fstat_sim = NONE;
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
|
||||
using fmt::format;
|
||||
using fmt::format_error;
|
||||
using fmt::internal::max_value;
|
||||
using fmt::detail::max_value;
|
||||
|
||||
const unsigned BIG_NUM = INT_MAX + 1u;
|
||||
|
||||
@@ -300,7 +300,7 @@ void TestLength(const char* length_spec, U value) {
|
||||
unsigned long long unsigned_value = 0;
|
||||
// Apply integer promotion to the argument.
|
||||
unsigned long long max = max_value<U>();
|
||||
using fmt::internal::const_check;
|
||||
using fmt::detail::const_check;
|
||||
if (const_check(max <= static_cast<unsigned>(max_value<int>()))) {
|
||||
signed_value = static_cast<int>(value);
|
||||
unsigned_value = static_cast<unsigned long long>(value);
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ template <> struct scanner<tm> {
|
||||
if (it != ctx.end() && *it == ':') ++it;
|
||||
auto end = it;
|
||||
while (end != ctx.end() && *end != '}') ++end;
|
||||
format.reserve(internal::to_unsigned(end - it + 1));
|
||||
format.reserve(detail::to_unsigned(end - it + 1));
|
||||
format.append(it, end);
|
||||
format.push_back('\0');
|
||||
return end;
|
||||
|
||||
+11
-11
@@ -31,7 +31,7 @@ class scan_parse_context {
|
||||
FMT_CONSTEXPR iterator end() const { return format_.end(); }
|
||||
|
||||
void advance_to(iterator it) {
|
||||
format_.remove_prefix(internal::to_unsigned(it - begin()));
|
||||
format_.remove_prefix(detail::to_unsigned(it - begin()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,11 +48,11 @@ struct scan_context {
|
||||
iterator end() const { return begin() + input_.size(); }
|
||||
|
||||
void advance_to(iterator it) {
|
||||
input_.remove_prefix(internal::to_unsigned(it - begin()));
|
||||
input_.remove_prefix(detail::to_unsigned(it - begin()));
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
enum class scan_type {
|
||||
none_type,
|
||||
int_type,
|
||||
@@ -107,20 +107,20 @@ class scan_arg {
|
||||
ctx.advance_to(s.scan(*static_cast<T*>(arg), ctx));
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
struct scan_args {
|
||||
int size;
|
||||
const internal::scan_arg* data;
|
||||
const detail::scan_arg* data;
|
||||
|
||||
template <size_t N>
|
||||
scan_args(const std::array<internal::scan_arg, N>& store)
|
||||
scan_args(const std::array<detail::scan_arg, N>& store)
|
||||
: size(N), data(store.data()) {
|
||||
static_assert(N < INT_MAX, "too many arguments");
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
struct scan_handler : error_handler {
|
||||
private:
|
||||
@@ -215,17 +215,17 @@ struct scan_handler : error_handler {
|
||||
return parse_ctx_.begin();
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
template <typename... Args>
|
||||
std::array<internal::scan_arg, sizeof...(Args)> make_scan_args(Args&... args) {
|
||||
std::array<detail::scan_arg, sizeof...(Args)> make_scan_args(Args&... args) {
|
||||
return {{args...}};
|
||||
}
|
||||
|
||||
string_view::iterator vscan(string_view input, string_view format_str,
|
||||
scan_args args) {
|
||||
internal::scan_handler h(format_str, input, args);
|
||||
internal::parse_format_string<false>(format_str, h);
|
||||
detail::scan_handler h(format_str, input, args);
|
||||
detail::parse_format_string<false>(format_str, h);
|
||||
return input.begin() + (h.pos() - &*input.begin());
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ template <> struct std::formatter<S> {
|
||||
if constexpr (!is_integral_v<type> || is_same_v<type, bool>)
|
||||
throw format_error("width is not integral");
|
||||
// else if (value < 0 || value > numeric_limits<int>::max())
|
||||
else if (fmt::internal::is_negative(value) ||
|
||||
else if (fmt::detail::is_negative(value) ||
|
||||
value > numeric_limits<int>::max())
|
||||
throw format_error("invalid width");
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user