aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorbulatman <bulatman@yandex-team.com>2025-01-10 01:27:33 +0300
committerbulatman <bulatman@yandex-team.com>2025-01-10 01:52:38 +0300
commitfab0037c69a3d2c1d81904e6174dcb4317ba02a2 (patch)
tree739af9c9206211c48fdabe6ef13feb1278f36a15 /library/cpp
parent667707fa06732f2943922d08ef77a2c9a52cbd47 (diff)
downloadydb-fab0037c69a3d2c1d81904e6174dcb4317ba02a2.tar.gz
YT: Removed extra trailing comma in std::tuple formatting
commit_hash:19b37bd3d7e3b4d80e4844676c881bbef1fec76b
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/yt/string/format-inl.h2
-rw-r--r--library/cpp/yt/string/unittests/format_ut.cpp7
2 files changed, 8 insertions, 1 deletions
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h
index e90d68bfe1..b18c435cb8 100644
--- a/library/cpp/yt/string/format-inl.h
+++ b/library/cpp/yt/string/format-inl.h
@@ -722,7 +722,7 @@ void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TS
[&] <size_t... Idx> (std::index_sequence<Idx...>) {
([&] {
FormatValue(builder, std::get<Idx>(value), spec);
- if constexpr (Idx != sizeof...(Ts)) {
+ if constexpr (Idx != sizeof...(Ts) - 1) {
builder->AppendString(TStringBuf(", "));
}
} (), ...);
diff --git a/library/cpp/yt/string/unittests/format_ut.cpp b/library/cpp/yt/string/unittests/format_ut.cpp
index 8aca8c8e29..e6b5eb7cfe 100644
--- a/library/cpp/yt/string/unittests/format_ut.cpp
+++ b/library/cpp/yt/string/unittests/format_ut.cpp
@@ -239,6 +239,13 @@ TEST(TFormatTest, Pointers)
}
}
+TEST(TFormatTest, Tuples)
+{
+ EXPECT_EQ("{}", Format("%v", std::tuple()));
+ EXPECT_EQ("{1, 2, 3}", Format("%v", std::tuple(1, 2, 3)));
+ EXPECT_EQ("{1, 2}", Format("%v", std::pair(1, 2)));
+}
+
TEST(TFormatTest, LazyMultiValueFormatter)
{
int i = 1;