Interpret precision as display width (#4443)

This commit is contained in:
Nikhil
2025-05-25 21:12:47 +05:30
committed by GitHub
parent 1ff0b7f5e1
commit 6d79757a38
2 changed files with 45 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
// For the license information refer to format.h.
// Check if fmt/format.h compiles with windows.h included before it.
#include <gtest/gtest.h>
#ifdef _WIN32
# include <windows.h>
#endif
@@ -552,6 +553,10 @@ TEST(format_test, arg_errors) {
format_error, "argument not found");
}
TEST(format_test, display_width_precision) {
EXPECT_EQ(fmt::format("{:.5}", "🐱🐱🐱"), "🐱🐱");
}
template <int N> struct test_format {
template <typename... T>
static auto format(fmt::string_view fmt, const T&... args) -> std::string {