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 <kefu.chai@scylladb.com>
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#define BOOST_TEST_MODULE utils
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#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<float>(seconds)};
|
||||
auto actual = out.str();
|
||||
std::string actual;
|
||||
fmt::format_to(std::back_inserter(actual), "{}", utils::pretty_printed_throughput{n, std::chrono::duration<float>(seconds)});
|
||||
BOOST_CHECK_EQUAL(actual, expected);
|
||||
|
||||
std::string s;
|
||||
fmt::format_to(std::back_inserter(s), "{}", utils::pretty_printed_throughput{n, std::chrono::duration<float>(seconds)});
|
||||
BOOST_CHECK_EQUAL(s, expected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "pretty_printers.hh"
|
||||
#include <fmt/ostream.h>
|
||||
#include <tuple>
|
||||
|
||||
template <typename Suffixes>
|
||||
@@ -82,17 +81,3 @@ auto fmt::formatter<utils::pretty_printed_throughput>::format<fmt::basic_format_
|
||||
const utils::pretty_printed_throughput&,
|
||||
fmt::basic_format_context<std::back_insert_iterator<std::string>, 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <ostream>
|
||||
#include <fmt/core.h>
|
||||
|
||||
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<pretty_printed_data_size>;
|
||||
};
|
||||
|
||||
@@ -29,7 +27,6 @@ class pretty_printed_throughput {
|
||||
public:
|
||||
pretty_printed_throughput(uint64_t size, std::chrono::duration<float> dur) : _size(size), _duration(std::move(dur)) {}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream&, pretty_printed_throughput);
|
||||
friend fmt::formatter<pretty_printed_throughput>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user