basic_buffer -> buffer

This reduces symbol sizes and gets rid of shadowing warnings.
This commit is contained in:
Victor Zverovich
2019-04-07 10:05:49 -07:00
parent 6e37c20030
commit 2808395481
14 changed files with 100 additions and 101 deletions

View File

@@ -31,7 +31,7 @@
using fmt::basic_format_arg;
using fmt::string_view;
using fmt::internal::basic_buffer;
using fmt::internal::buffer;
using fmt::internal::value;
using testing::_;
@@ -54,7 +54,7 @@ template <typename Char> struct formatter<test_struct, Char> {
return ctx.begin();
}
typedef std::back_insert_iterator<basic_buffer<Char>> iterator;
typedef std::back_insert_iterator<buffer<Char>> iterator;
auto format(test_struct, basic_format_context<iterator, char>& ctx)
-> decltype(ctx.out()) {
@@ -66,28 +66,28 @@ FMT_END_NAMESPACE
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 470
TEST(BufferTest, Noncopyable) {
EXPECT_FALSE(std::is_copy_constructible<basic_buffer<char>>::value);
EXPECT_FALSE(std::is_copy_constructible<buffer<char>>::value);
# if !FMT_MSC_VER
// std::is_copy_assignable is broken in MSVC2013.
EXPECT_FALSE(std::is_copy_assignable<basic_buffer<char>>::value);
EXPECT_FALSE(std::is_copy_assignable<buffer<char>>::value);
# endif
}
TEST(BufferTest, Nonmoveable) {
EXPECT_FALSE(std::is_move_constructible<basic_buffer<char>>::value);
EXPECT_FALSE(std::is_move_constructible<buffer<char>>::value);
# if !FMT_MSC_VER
// std::is_move_assignable is broken in MSVC2013.
EXPECT_FALSE(std::is_move_assignable<basic_buffer<char>>::value);
EXPECT_FALSE(std::is_move_assignable<buffer<char>>::value);
# endif
}
#endif
// A test buffer with a dummy grow method.
template <typename T> struct test_buffer : basic_buffer<T> {
template <typename T> struct test_buffer : buffer<T> {
void grow(std::size_t capacity) { this->set(FMT_NULL, capacity); }
};
template <typename T> struct mock_buffer : basic_buffer<T> {
template <typename T> struct mock_buffer : buffer<T> {
MOCK_METHOD1(do_grow, void(std::size_t capacity));
void grow(std::size_t capacity) {
@@ -133,7 +133,7 @@ TEST(BufferTest, VirtualDtor) {
typedef StrictMock<dying_buffer> stict_mock_buffer;
stict_mock_buffer* mock_buffer = new stict_mock_buffer();
EXPECT_CALL(*mock_buffer, die());
basic_buffer<int>* buffer = mock_buffer;
buffer<int>* buffer = mock_buffer;
delete buffer;
}
@@ -144,7 +144,7 @@ TEST(BufferTest, Access) {
EXPECT_EQ(11, buffer[0]);
buffer[3] = 42;
EXPECT_EQ(42, *(&buffer[0] + 3));
const basic_buffer<char>& const_buffer = buffer;
const fmt::internal::buffer<char>& const_buffer = buffer;
EXPECT_EQ(42, const_buffer[3]);
}
@@ -293,7 +293,7 @@ VISIT_TYPE(float, double);
{ \
testing::StrictMock<mock_visitor<decltype(expected)>> visitor; \
EXPECT_CALL(visitor, visit(expected)); \
typedef std::back_insert_iterator<basic_buffer<Char>> iterator; \
typedef std::back_insert_iterator<buffer<Char>> iterator; \
fmt::visit_format_arg( \
visitor, make_arg<fmt::basic_format_context<iterator, Char>>(value)); \
}
@@ -371,12 +371,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::basic_buffer<char> {
struct test_buffer : fmt::internal::buffer<char> {
char data[10];
test_buffer() : fmt::internal::basic_buffer<char>(data, 0, 10) {}
test_buffer() : fmt::internal::buffer<char>(data, 0, 10) {}
void grow(std::size_t) {}
} buffer;
fmt::internal::basic_buffer<char>& base = buffer;
fmt::internal::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);

View File

@@ -14,9 +14,10 @@
// A custom argument formatter that doesn't print `-` for floating-point values
// rounded to 0.
class custom_arg_formatter
: public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> {
: public fmt::arg_formatter<
fmt::back_insert_range<fmt::internal::buffer<char>>> {
public:
typedef fmt::back_insert_range<fmt::internal::buffer> range;
typedef fmt::back_insert_range<fmt::internal::buffer<char>> range;
typedef fmt::arg_formatter<range> base;
custom_arg_formatter(fmt::format_context& ctx,

View File

@@ -20,8 +20,8 @@
# include <windows.h>
#endif
#include "fmt/format.h"
#include "fmt/color.h"
#include "fmt/format.h"
#include "gmock.h"
#include "gtest-extra.h"
#include "mock-allocator.h"
@@ -103,7 +103,7 @@ void std_format(long double value, std::wstring& result) {
template <typename Char, typename T>
::testing::AssertionResult check_write(const T& value, const char* type) {
fmt::basic_memory_buffer<Char> buffer;
typedef fmt::back_insert_range<fmt::internal::basic_buffer<Char>> range;
typedef fmt::back_insert_range<fmt::internal::buffer<Char>> range;
fmt::basic_writer<range> writer(buffer);
writer.write(value);
std::basic_string<Char> actual = to_string(buffer);
@@ -472,8 +472,8 @@ TEST(UtilTest, UTF16ToUTF8Convert) {
}
#endif // _WIN32
typedef void (*FormatErrorMessage)(fmt::internal::buffer& out, int error_code,
string_view message);
typedef void (*FormatErrorMessage)(fmt::internal::buffer<char>& out,
int error_code, string_view message);
template <typename Error>
void check_throw_error(int error_code, FormatErrorMessage format) {
@@ -705,7 +705,8 @@ TEST(WriterTest, WriteUIntPtr) {
memory_buffer buf;
fmt::writer writer(buf);
writer.write_pointer(fmt::internal::bit_cast<fmt::internal::uintptr_t>(
reinterpret_cast<void*>(0xface)), FMT_NULL);
reinterpret_cast<void*>(0xface)),
FMT_NULL);
EXPECT_EQ("0xface", to_string(buf));
}
@@ -1948,7 +1949,7 @@ enum TestFixedEnum : short { B };
TEST(FormatTest, FixedEnum) { EXPECT_EQ("0", fmt::format("{}", B)); }
#endif
typedef fmt::back_insert_range<fmt::internal::buffer> buffer_range;
typedef fmt::back_insert_range<fmt::internal::buffer<char>> buffer_range;
class mock_arg_formatter
: public fmt::internal::function<

View File

@@ -51,7 +51,7 @@ TEST(OStreamTest, Enum) {
EXPECT_EQ(L"0", fmt::format(L"{}", A));
}
typedef fmt::back_insert_range<fmt::internal::buffer> range;
typedef fmt::back_insert_range<fmt::internal::buffer<char>> range;
struct test_arg_formatter : fmt::arg_formatter<range> {
fmt::format_parse_context parse_ctx;
@@ -61,7 +61,7 @@ struct test_arg_formatter : fmt::arg_formatter<range> {
TEST(OStreamTest, CustomArg) {
fmt::memory_buffer buffer;
fmt::internal::buffer& base = buffer;
fmt::internal::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);
@@ -134,7 +134,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
std::streamsize max_streamsize = std::numeric_limits<std::streamsize>::max();
if (max_size <= fmt::internal::to_unsigned(max_streamsize)) return;
struct test_buffer : fmt::internal::buffer {
struct test_buffer : fmt::internal::buffer<char> {
explicit test_buffer(std::size_t size) { resize(size); }
void grow(std::size_t) {}
} buffer(max_size);

View File

@@ -44,8 +44,8 @@ TEST(RangesTest, FormatPair) {
}
TEST(RangesTest, FormatTuple) {
std::tuple<int64_t, float, std::string, char> tu1{42, 1.5f,
"this is tuple", 'i'};
std::tuple<int64_t, float, std::string, char> tu1{42, 1.5f, "this is tuple",
'i'};
EXPECT_EQ("(42, 1.5, \"this is tuple\", 'i')", fmt::format("{}", tu1));
}