Clean the buffer API (#477)

This commit is contained in:
Victor Zverovich
2017-03-12 09:48:21 -07:00
parent f423e46835
commit b4f4b7e21a
4 changed files with 59 additions and 49 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
return;
struct TestBuffer : fmt::basic_buffer<char> {
explicit TestBuffer(std::size_t size) { size_ = size; }
explicit TestBuffer(std::size_t size) { resize(size); }
void grow(std::size_t) {}
} buffer(max_size);
+7 -7
View File
@@ -120,21 +120,21 @@ TEST(BufferTest, Nonmoveable) {
// A test buffer with a dummy grow method.
template <typename T>
struct TestBuffer : basic_buffer<T> {
void grow(std::size_t size) { this->capacity_ = size; }
void grow(std::size_t capacity) { this->set(0, capacity); }
};
template <typename T>
struct MockBuffer : basic_buffer<T> {
MOCK_METHOD1(do_grow, void (std::size_t size));
MOCK_METHOD1(do_grow, void (std::size_t capacity));
void grow(std::size_t size) {
this->capacity_ = size;
do_grow(size);
void grow(std::size_t capacity) {
this->set(this->data(), capacity);
do_grow(capacity);
}
MockBuffer() {}
MockBuffer(T *ptr) : basic_buffer<T>(ptr) {}
MockBuffer(T *ptr, std::size_t capacity) : basic_buffer<T>(ptr, capacity) {}
MockBuffer(T *data) { this->set(data, 0); }
MockBuffer(T *data, std::size_t capacity) { this->set(data, capacity); }
};
TEST(BufferTest, Ctor) {