From a8254111efd7f6c2a01a57aa99d6fcdc9b9ed6c7 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 17 Jul 2023 13:32:26 +0800 Subject: [PATCH] utils: drop operator<< for pretty printers since all callers of these operators have switched to fmt formatters. let's drop them. the tests are updated accordingly. Signed-off-by: Kefu Chai --- test/boost/pretty_printers_test.cc | 19 ++++--------------- utils/pretty_printers.cc | 15 --------------- utils/pretty_printers.hh | 3 --- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/test/boost/pretty_printers_test.cc b/test/boost/pretty_printers_test.cc index 5bd2260f01..d3fccc9b91 100644 --- a/test/boost/pretty_printers_test.cc +++ b/test/boost/pretty_printers_test.cc @@ -9,7 +9,6 @@ #define BOOST_TEST_MODULE utils #include -#include #include #include "utils/pretty_printers.hh" @@ -29,14 +28,9 @@ BOOST_AUTO_TEST_CASE(test_print_data_size) { {10'000'000'000'000'000'000ULL, "10000PB"}, }; for (auto [n, expected] : sizes) { - std::stringstream out; - out << utils::pretty_printed_data_size{n}; - auto actual = out.str(); + std::string actual; + fmt::format_to(std::back_inserter(actual), "{}", utils::pretty_printed_data_size{n}); BOOST_CHECK_EQUAL(actual, expected); - - std::string s; - fmt::format_to(std::back_inserter(s), "{}", utils::pretty_printed_data_size{n}); - BOOST_CHECK_EQUAL(s, expected); } } @@ -54,13 +48,8 @@ BOOST_AUTO_TEST_CASE(test_print_throughput) { {10'000'000ULL, 0.5F, "20MB/s"}, }; for (auto [n, seconds, expected] : sizes) { - std::stringstream out; - out << utils::pretty_printed_throughput{n, std::chrono::duration(seconds)}; - auto actual = out.str(); + std::string actual; + fmt::format_to(std::back_inserter(actual), "{}", utils::pretty_printed_throughput{n, std::chrono::duration(seconds)}); BOOST_CHECK_EQUAL(actual, expected); - - std::string s; - fmt::format_to(std::back_inserter(s), "{}", utils::pretty_printed_throughput{n, std::chrono::duration(seconds)}); - BOOST_CHECK_EQUAL(s, expected); } } diff --git a/utils/pretty_printers.cc b/utils/pretty_printers.cc index 71b5fe2733..b87a13a74b 100644 --- a/utils/pretty_printers.cc +++ b/utils/pretty_printers.cc @@ -7,7 +7,6 @@ */ #include "pretty_printers.hh" -#include #include template @@ -82,17 +81,3 @@ auto fmt::formatter::format, char>& ctx) const -> decltype(ctx.out()); - -namespace utils { - -std::ostream& operator<<(std::ostream& os, pretty_printed_data_size data) { - fmt::print(os, "{}", data); - return os; -} - -std::ostream& operator<<(std::ostream& os, pretty_printed_throughput tp) { - fmt::print(os, "{}", tp); - return os; -} - -} diff --git a/utils/pretty_printers.hh b/utils/pretty_printers.hh index 0bf00cafe3..e1d44ab717 100644 --- a/utils/pretty_printers.hh +++ b/utils/pretty_printers.hh @@ -9,7 +9,6 @@ #pragma once #include -#include #include namespace utils { @@ -19,7 +18,6 @@ class pretty_printed_data_size { public: pretty_printed_data_size(uint64_t size) : _size(size) {} - friend std::ostream& operator<<(std::ostream&, pretty_printed_data_size); friend fmt::formatter; }; @@ -29,7 +27,6 @@ class pretty_printed_throughput { public: pretty_printed_throughput(uint64_t size, std::chrono::duration dur) : _size(size), _duration(std::move(dur)) {} - friend std::ostream& operator<<(std::ostream&, pretty_printed_throughput); friend fmt::formatter; };