Skip to content

Commit

Permalink
fix ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Gray committed Nov 30, 2020
1 parent 314ed9d commit c3a8277
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
10 changes: 5 additions & 5 deletions include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::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;
}

Expand Down Expand Up @@ -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, " ... <other elements>");
out = format_to(out, FMT_STRING(" ... <other elements>"));
break;
}
}
Expand Down
21 changes: 6 additions & 15 deletions test/enforce-compiletime-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ TEST(ChronoTest, FormatFullSpecs) {

TEST(ChronoTest, FormatSimpleQq) {
typedef std::chrono::duration<float> 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<float, std::milli> fms;
EXPECT_EQ("1.234 ms", fmt::format(FMT_STRING("{:%Q %q}"), fms(1.234)));
typedef std::chrono::duration<double> ds;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -683,10 +675,9 @@ template <typename T> class noncopyable_range {
const_iterator end() const { return vec.end(); }
};

// TODO: Fixme
TEST(RangesTest, Range) {
noncopyable_range<int> 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<int>(3u, 0)));

Expand All @@ -701,7 +692,7 @@ TEST(RangesTest, Range) {
0)));

const std::vector<int> 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
Expand Down

0 comments on commit c3a8277

Please sign in to comment.