Commit 8d3fd86d authored by Victor Zverovich's avatar Victor Zverovich

Merge branch 'master' of github.com:fmtlib/fmt

parents 010efc31 40347157
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
:alt: fmt is continuously fuzzed at oss-fuzz :alt: fmt is continuously fuzzed at oss-fuzz
:target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\ :target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\
colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\ colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\
Summary&q=proj%3Dlibfmt&can=1 Summary&q=proj%3Dfmt&can=1
.. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg .. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg
:alt: Ask questions at StackOverflow with the tag fmt :alt: Ask questions at StackOverflow with the tag fmt
...@@ -57,7 +57,7 @@ Features ...@@ -57,7 +57,7 @@ Features
* Reliability: the library has an extensive set of `tests * Reliability: the library has an extensive set of `tests
<https://github.com/fmtlib/fmt/tree/master/test>`_ and is `continuously fuzzed <https://github.com/fmtlib/fmt/tree/master/test>`_ and is `continuously fuzzed
<https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20 <https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20
Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dlibfmt&can=1>`_ Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1>`_
* Safety: the library is fully type safe, errors in format strings can be * Safety: the library is fully type safe, errors in format strings can be
reported at compile time, automatic memory management prevents buffer overflow reported at compile time, automatic memory management prevents buffer overflow
errors errors
......
...@@ -761,7 +761,7 @@ class fixed_buffer_traits { ...@@ -761,7 +761,7 @@ class fixed_buffer_traits {
// A buffer that writes to an output iterator when flushed. // A buffer that writes to an output iterator when flushed.
template <typename OutputIt, typename T, typename Traits = buffer_traits> template <typename OutputIt, typename T, typename Traits = buffer_traits>
class iterator_buffer : public Traits, public buffer<T> { class iterator_buffer final : public Traits, public buffer<T> {
private: private:
OutputIt out_; OutputIt out_;
enum { buffer_size = 256 }; enum { buffer_size = 256 };
...@@ -787,7 +787,7 @@ class iterator_buffer : public Traits, public buffer<T> { ...@@ -787,7 +787,7 @@ class iterator_buffer : public Traits, public buffer<T> {
size_t count() const { return Traits::count() + this->size(); } size_t count() const { return Traits::count() + this->size(); }
}; };
template <typename T> class iterator_buffer<T*, T> : public buffer<T> { template <typename T> class iterator_buffer<T*, T> final : public buffer<T> {
protected: protected:
void grow(size_t) final FMT_OVERRIDE {} void grow(size_t) final FMT_OVERRIDE {}
...@@ -801,7 +801,7 @@ template <typename T> class iterator_buffer<T*, T> : public buffer<T> { ...@@ -801,7 +801,7 @@ template <typename T> class iterator_buffer<T*, T> : public buffer<T> {
template <typename Container> template <typename Container>
class iterator_buffer<std::back_insert_iterator<Container>, class iterator_buffer<std::back_insert_iterator<Container>,
enable_if_t<is_contiguous<Container>::value, enable_if_t<is_contiguous<Container>::value,
typename Container::value_type>> typename Container::value_type>> final
: public buffer<typename Container::value_type> { : public buffer<typename Container::value_type> {
private: private:
Container& container_; Container& container_;
...@@ -823,7 +823,7 @@ class iterator_buffer<std::back_insert_iterator<Container>, ...@@ -823,7 +823,7 @@ class iterator_buffer<std::back_insert_iterator<Container>,
}; };
// A buffer that counts the number of code units written discarding the output. // A buffer that counts the number of code units written discarding the output.
template <typename T = char> class counting_buffer : public buffer<T> { template <typename T = char> class counting_buffer final : public buffer<T> {
private: private:
enum { buffer_size = 256 }; enum { buffer_size = 256 };
T data_[buffer_size]; T data_[buffer_size];
......
...@@ -651,7 +651,7 @@ enum { inline_buffer_size = 500 }; ...@@ -651,7 +651,7 @@ enum { inline_buffer_size = 500 };
*/ */
template <typename T, size_t SIZE = inline_buffer_size, template <typename T, size_t SIZE = inline_buffer_size,
typename Allocator = std::allocator<T>> typename Allocator = std::allocator<T>>
class basic_memory_buffer : public detail::buffer<T> { class basic_memory_buffer final : public detail::buffer<T> {
private: private:
T store_[SIZE]; T store_[SIZE];
......
...@@ -378,7 +378,7 @@ struct ostream_params { ...@@ -378,7 +378,7 @@ struct ostream_params {
static constexpr detail::buffer_size buffer_size; static constexpr detail::buffer_size buffer_size;
// A fast output stream which is not thread-safe. // A fast output stream which is not thread-safe.
class ostream : private detail::buffer<char> { class ostream final : private detail::buffer<char> {
private: private:
file file_; file file_;
......
...@@ -78,7 +78,7 @@ TEST(BufferTest, Indestructible) { ...@@ -78,7 +78,7 @@ TEST(BufferTest, Indestructible) {
"buffer's destructor is protected"); "buffer's destructor is protected");
} }
template <typename T> struct mock_buffer : buffer<T> { template <typename T> struct mock_buffer final : buffer<T> {
MOCK_METHOD1(do_grow, size_t(size_t capacity)); 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) { this->set(this->data(), do_grow(capacity)); }
...@@ -368,7 +368,7 @@ TEST(ArgTest, PointerArg) { ...@@ -368,7 +368,7 @@ TEST(ArgTest, PointerArg) {
struct check_custom { struct check_custom {
test_result operator()( test_result operator()(
fmt::basic_format_arg<fmt::format_context>::handle h) const { fmt::basic_format_arg<fmt::format_context>::handle h) const {
struct test_buffer : fmt::detail::buffer<char> { struct test_buffer final : fmt::detail::buffer<char> {
char data[10]; char data[10];
test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {} test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
void grow(size_t) {} void grow(size_t) {}
......
...@@ -293,12 +293,8 @@ TEST(MemoryBufferTest, MoveAssignment) { ...@@ -293,12 +293,8 @@ TEST(MemoryBufferTest, MoveAssignment) {
TEST(MemoryBufferTest, Grow) { TEST(MemoryBufferTest, Grow) {
typedef allocator_ref<mock_allocator<int>> Allocator; typedef allocator_ref<mock_allocator<int>> Allocator;
typedef basic_memory_buffer<int, 10, Allocator> Base;
mock_allocator<int> alloc; mock_allocator<int> alloc;
struct TestMemoryBuffer : Base { basic_memory_buffer<int, 10, Allocator> buffer((Allocator(&alloc)));
TestMemoryBuffer(Allocator alloc) : Base(alloc) {}
using Base::grow;
} buffer((Allocator(&alloc)));
buffer.resize(7); buffer.resize(7);
using fmt::detail::to_unsigned; using fmt::detail::to_unsigned;
for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i; for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i;
...@@ -306,7 +302,7 @@ TEST(MemoryBufferTest, Grow) { ...@@ -306,7 +302,7 @@ TEST(MemoryBufferTest, Grow) {
int mem[20]; int mem[20];
mem[7] = 0xdead; mem[7] = 0xdead;
EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem)); EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem));
buffer.grow(20); buffer.try_reserve(20);
EXPECT_EQ(20u, buffer.capacity()); EXPECT_EQ(20u, buffer.capacity());
// Check if size elements have been copied // Check if size elements have been copied
for (int i = 0; i < 7; ++i) EXPECT_EQ(i * i, buffer[to_unsigned(i)]); for (int i = 0; i < 7; ++i) EXPECT_EQ(i * i, buffer[to_unsigned(i)]);
......
...@@ -150,7 +150,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { ...@@ -150,7 +150,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>(); std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>();
if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return; if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;
struct test_buffer : fmt::detail::buffer<char> { struct test_buffer final : fmt::detail::buffer<char> {
explicit test_buffer(size_t size) explicit test_buffer(size_t size)
: fmt::detail::buffer<char>(nullptr, size, size) {} : fmt::detail::buffer<char>(nullptr, size, size) {}
void grow(size_t) {} void grow(size_t) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment