Fix handling of output iterator in ranges

This commit is contained in:
Victor Zverovich
2019-03-06 07:59:23 -08:00
parent 79b79f329e
commit 2e526a664a
2 changed files with 34 additions and 32 deletions

View File

@@ -39,14 +39,14 @@ TEST(RangesTest, FormatMap) {
}
TEST(RangesTest, FormatPair) {
std::pair<int64_t, float> pa1{42, 3.14159265358979f};
EXPECT_EQ("(42, 3.14159)", fmt::format("{}", pa1));
std::pair<int64_t, float> pa1{42, 1.5f};
EXPECT_EQ("(42, 1.5)", fmt::format("{}", pa1));
}
TEST(RangesTest, FormatTuple) {
std::tuple<int64_t, float, std::string, char> tu1{42, 3.14159265358979f,
std::tuple<int64_t, float, std::string, char> tu1{42, 1.5f,
"this is tuple", 'i'};
EXPECT_EQ("(42, 3.14159, \"this is tuple\", 'i')", fmt::format("{}", tu1));
EXPECT_EQ("(42, 1.5, \"this is tuple\", 'i')", fmt::format("{}", tu1));
}
struct my_struct {
@@ -80,5 +80,12 @@ TEST(RangesTest, FormatStruct) {
EXPECT_EQ("(13, \"my struct\")", fmt::format("{}", mst));
}
TEST(RangesTest, FormatTo) {
char buf[10];
auto end = fmt::format_to(buf, "{}", std::vector{1, 2, 3});
*end = '\0';
EXPECT_STREQ(buf, "{1, 2, 3}");
}
#endif // (__cplusplus > 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >
// 201402L && _MSC_VER >= 1910)