From c46a8de4e1e4e84ec285b63e5fa995ca3a47c370 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 20 Sep 2020 06:59:01 -0700 Subject: [PATCH] Simplify test --- test/compile-test.cc | 48 ++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/test/compile-test.cc b/test/compile-test.cc index f1fd65b3..b79b9ea9 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -155,9 +155,6 @@ TEST(CompileTest, FormatWideString) { TEST(CompileTest, FormatSpecs) { EXPECT_EQ("42", fmt::format(FMT_COMPILE("{:x}"), 0x42)); - EXPECT_EQ("1.234000:0042:+3.13:str:0x3e8:X", - fmt::format(FMT_COMPILE("{:.6f}:{:04}:{:+}:{}:{}:{}"), 1.234, 42, - 3.13, "str", reinterpret_cast(1000), 'X')); } TEST(CompileTest, DynamicWidth) { @@ -166,39 +163,24 @@ TEST(CompileTest, DynamicWidth) { } TEST(CompileTest, FormatTo) { - { - char buf[8]; - auto end = fmt::format_to(buf, FMT_COMPILE("{}"), 42); - *end = '\0'; - EXPECT_STREQ("42", buf); - } - { - char buf[100]; - auto end = - fmt::format_to(buf, FMT_COMPILE("{:.6f}:{:04}:{:+}:{}:{}:{}"), 1.234, - 42, 3.13, "str", reinterpret_cast(1000), 'X'); - *end = '\0'; - EXPECT_STREQ("1.234000:0042:+3.13:str:0x3e8:X", buf); - } + char buf[8]; + auto end = fmt::format_to(buf, FMT_COMPILE("{}"), 42); + *end = '\0'; + EXPECT_STREQ("42", buf); + end = fmt::format_to(buf, FMT_COMPILE("{:x}"), 42); + *end = '\0'; + EXPECT_STREQ("2a", buf); } TEST(CompileTest, FormatToNWithCompileMacro) { - { - constexpr auto buffer_size = 8; - char buffer[buffer_size]; - auto res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{}"), 42); - *res.out = '\0'; - EXPECT_STREQ("42", buffer); - } - { - constexpr auto buffer_size = 100; - char buffer[buffer_size]; - auto res = fmt::format_to_n( - buffer, buffer_size, FMT_COMPILE("{:.6f}:{:04}:{:+}:{}:{}:{}"), 1.234, - 42, 3.13, "str", reinterpret_cast(1000), 'X'); - *res.out = '\0'; - EXPECT_STREQ("1.234000:0042:+3.13:str:0x3e8:X", buffer); - } + constexpr auto buffer_size = 8; + char buffer[buffer_size]; + auto res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{}"), 42); + *res.out = '\0'; + EXPECT_STREQ("42", buffer); + res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{:x}"), 42); + *res.out = '\0'; + EXPECT_STREQ("2a", buffer); } TEST(CompileTest, TextAndArg) {