Skip to content

Commit

Permalink
Merge 'test: changes to prepare for dropping FMT_DEPRECATED_OSTREAM' …
Browse files Browse the repository at this point in the history
…from Kefu Chai

this series includes test related changes to enable us to drop `FMT_DEPRECATED_OSTREAM` deprecated in {fmt} v10.

Refs scylladb#13245

Closes scylladb#18054

* github.com:scylladb/scylladb:
  test: unit: add fmt::formatter for test_data in tests
  test/lib: do not print with fmt::to_string()
  test/boost: print runtime_error using e.what()
  • Loading branch information
denesb committed Mar 28, 2024
2 parents 33751f8 + 71a519d commit 4c0dade
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions test/boost/database_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,9 @@ SEASTAR_THREAD_TEST_CASE(read_max_size) {
}
} catch (std::runtime_error& e) {
if (should_throw) {
testlog.trace("Exception thrown, as expected: {}", e);
testlog.trace("Exception thrown, as expected: {}", e.what());
} else {
BOOST_FAIL(fmt::format("Expected no exception, but caught: {}", e));
BOOST_FAIL(fmt::format("Expected no exception, but caught: {}", e.what()));
}
}
}
Expand Down Expand Up @@ -1044,7 +1044,7 @@ SEASTAR_THREAD_TEST_CASE(unpaged_mutation_read_global_limit) {
BOOST_REQUIRE(size != 0);
BOOST_FAIL("Expected exception, but none was thrown.");
} catch (std::runtime_error& e) {
testlog.trace("Exception thrown, as expected: {}", e);
testlog.trace("Exception thrown, as expected: {}", e.what());
}
}
}, std::move(cfg)).get();
Expand Down
2 changes: 1 addition & 1 deletion test/lib/cql_assertions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rows_assertions::is_empty() {
auto row_count = rs.size();
if (row_count != 0) {
auto&& first_row = *rs.rows().begin();
fail(format("Expected no rows, but got {:d}. First row: {}", row_count, fmt::to_string(first_row)));
fail(format("Expected no rows, but got {:d}. First row: {}", row_count, first_row));
}
return {*this};
}
Expand Down
9 changes: 5 additions & 4 deletions test/unit/radix_tree_stress_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class test_data {
}
};

std::ostream& operator<<(std::ostream& out, const test_data& d) {
out << d.value();
return out;
}
template <> struct fmt::formatter<test_data> : fmt::formatter<std::string_view> {
auto format(const test_data& d, fmt::format_context& ctx) const {
return fmt::format_to(ctx.out(), "{}", d.value());
}
};

using test_tree = tree<test_data>;

Expand Down

0 comments on commit 4c0dade

Please sign in to comment.