mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-21 17:47:13 +02:00
Update cppfmt to current git.
This commit is contained in:
46
vendor/Fmt/test/core-test.cc
vendored
46
vendor/Fmt/test/core-test.cc
vendored
@ -151,7 +151,9 @@ TEST(buffer_test, indestructible) {
|
||||
template <typename T> struct mock_buffer final : buffer<T> {
|
||||
MOCK_METHOD1(do_grow, size_t(size_t capacity));
|
||||
|
||||
void grow(size_t capacity) { this->set(this->data(), do_grow(capacity)); }
|
||||
void grow(size_t capacity) override {
|
||||
this->set(this->data(), do_grow(capacity));
|
||||
}
|
||||
|
||||
mock_buffer(T* data = nullptr, size_t buf_capacity = 0) {
|
||||
this->set(data, buf_capacity);
|
||||
@ -452,7 +454,7 @@ struct check_custom {
|
||||
struct test_buffer final : fmt::detail::buffer<char> {
|
||||
char data[10];
|
||||
test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
|
||||
void grow(size_t) {}
|
||||
void grow(size_t) override {}
|
||||
} buffer;
|
||||
auto parse_ctx = fmt::format_parse_context("");
|
||||
auto ctx = fmt::format_context(fmt::detail::buffer_appender<char>(buffer),
|
||||
@ -845,3 +847,43 @@ TEST(core_test, adl) {
|
||||
fmt::print("{}", s);
|
||||
fmt::print(stdout, "{}", s);
|
||||
}
|
||||
|
||||
struct const_formattable {};
|
||||
struct nonconst_formattable {};
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <> struct formatter<const_formattable> {
|
||||
auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
auto format(const const_formattable&, format_context& ctx)
|
||||
-> decltype(ctx.out()) {
|
||||
auto test = string_view("test");
|
||||
return std::copy_n(test.data(), test.size(), ctx.out());
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct formatter<nonconst_formattable> {
|
||||
auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
auto format(nonconst_formattable&, format_context& ctx)
|
||||
-> decltype(ctx.out()) {
|
||||
auto test = string_view("test");
|
||||
return std::copy_n(test.data(), test.size(), ctx.out());
|
||||
}
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
TEST(core_test, is_const_formattable) {
|
||||
EXPECT_TRUE((fmt::detail::is_const_formattable<const_formattable,
|
||||
fmt::format_context>()));
|
||||
EXPECT_FALSE((fmt::detail::is_const_formattable<nonconst_formattable,
|
||||
fmt::format_context>()));
|
||||
}
|
||||
|
||||
TEST(core_test, format_nonconst) {
|
||||
EXPECT_EQ(fmt::format("{}", nonconst_formattable()), "test");
|
||||
}
|
||||
|
Reference in New Issue
Block a user