diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 732d320947013..05ad4952c208e 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -291,10 +291,10 @@ struct formatter::value>> { } out = detail::copy(formatting.delimiter, out); } - out = format_to(out, + out = vformat_to(out, detail::format_str_quoted( (formatting.add_delimiter_spaces && i > 0), v), - v); + make_format_args(v)); ++i; } @@ -366,12 +366,12 @@ struct formatter< if (formatting.add_prepostfix_space) *out++ = ' '; out = detail::copy(formatting.delimiter, out); } - out = format_to(out, + out = vformat_to(out, detail::format_str_quoted( (formatting.add_delimiter_spaces && i > 0), *it), - *it); + make_format_args(*it)); if (++i > formatting.range_length_limit) { - out = format_to(out, " ... "); + out = format_to(out, FMT_STRING(" ... ")); break; } } diff --git a/test/enforce-compiletime-test.cc b/test/enforce-compiletime-test.cc index db5f0c5687e2b..27a5c561e6cfc 100644 --- a/test/enforce-compiletime-test.cc +++ b/test/enforce-compiletime-test.cc @@ -316,7 +316,7 @@ TEST(ChronoTest, FormatFullSpecs) { TEST(ChronoTest, FormatSimpleQq) { typedef std::chrono::duration fs; - // EXPECT_EQ("1.234 s", fmt::format(FMT_STRING("{:%Q %q}"), fs(1.234))); + EXPECT_EQ("1.234 s", fmt::format(FMT_STRING("{:%Q %q}"), fs(1.234))); typedef std::chrono::duration fms; EXPECT_EQ("1.234 ms", fmt::format(FMT_STRING("{:%Q %q}"), fms(1.234))); typedef std::chrono::duration ds; @@ -404,13 +404,6 @@ TEST(ColorsTest, FormatToOutAcceptsTextStyle) { "\x1b[38;2;255;020;030mrgb(255,20,30)123\x1b[0m"); } -// Formatting library for C++ - std::ostream support tests -// -// Copyright (c) 2012 - present, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - struct test {}; // Test that there is no issues with specializations when fmt/ostream.h is @@ -637,12 +630,11 @@ struct zstring { zstring_sentinel end() const { return {}; } }; -// TODO: Fix using zstrings with FMT_STRING TEST(RangesTest, JoinSentinel) { zstring hello{"hello"}; - // EXPECT_EQ("{'h', 'e', 'l', 'l', 'o'}", fmt::format(FMT_STRING("{}"), - // hello)); EXPECT_EQ("h_e_l_l_o", fmt::format(FMT_STRING("{}"), - // fmt::join(hello, "_"))); + EXPECT_EQ("{'h', 'e', 'l', 'l', 'o'}", fmt::format(FMT_STRING("{}"), + hello)); EXPECT_EQ("h_e_l_l_o", fmt::format(FMT_STRING("{}"), + fmt::join(hello, "_"))); } // A range that provides non-const only begin()/end() to test fmt::join handles @@ -683,10 +675,9 @@ template class noncopyable_range { const_iterator end() const { return vec.end(); } }; -// TODO: Fixme TEST(RangesTest, Range) { noncopyable_range w(3u, 0); - /*EXPECT_EQ("{0, 0, 0}", fmt::format(FMT_STRING("{}"), w)); + EXPECT_EQ("{0, 0, 0}", fmt::format(FMT_STRING("{}"), w)); EXPECT_EQ("{0, 0, 0}", fmt::format(FMT_STRING("{}"), noncopyable_range(3u, 0))); @@ -701,7 +692,7 @@ TEST(RangesTest, Range) { 0))); const std::vector z(3u, 0); - EXPECT_EQ("{0, 0, 0}", fmt::format(FMT_STRING("{}"), z));*/ + EXPECT_EQ("{0, 0, 0}", fmt::format(FMT_STRING("{}"), z)); } #if !FMT_MSC_VER || FMT_MSC_VER >= 1927