Fix an inconsistentcy between to_string and format

This commit is contained in:
Victor Zverovich
2023-10-28 08:05:11 -07:00
parent 2a2c6e676f
commit 19276d7325
2 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -59,13 +59,18 @@ TEST(ranges_test, format_vector) {
EXPECT_EQ(fmt::format("{:n:n:}", vvc), "a, b, c, a, b, c");
}
TEST(ranges_test, format_vector2) {
TEST(ranges_test, format_nested_vector) {
auto v = std::vector<std::vector<int>>{{1, 2}, {3, 5}, {7, 11}};
EXPECT_EQ(fmt::format("{}", v), "[[1, 2], [3, 5], [7, 11]]");
EXPECT_EQ(fmt::format("{:::#x}", v), "[[0x1, 0x2], [0x3, 0x5], [0x7, 0xb]]");
EXPECT_EQ(fmt::format("{:n:n:#x}", v), "0x1, 0x2, 0x3, 0x5, 0x7, 0xb");
}
TEST(ranges_test, to_string_vector) {
auto v = std::vector<std::string>{"a", "b", "c"};
EXPECT_EQ(fmt::to_string(v), "[\"a\", \"b\", \"c\"]");
}
TEST(ranges_test, format_map) {
auto m = std::map<std::string, int>{{"one", 1}, {"two", 2}};
EXPECT_EQ(fmt::format("{}", m), "{\"one\": 1, \"two\": 2}");