mirror of
https://github.com/fmtlib/fmt.git
synced 2026-05-05 03:54:10 +02:00
Add fmt::format and deprecate fmt::Format.
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ expect_compile_error("fmt::internal::Array<char, 5> a, b(a);")
|
||||
expect_compile_error("fmt::internal::Array<char, 5> a, b; b = a;")
|
||||
|
||||
# Writer is noncopyable.
|
||||
expect_compile_error("fmt::Writer a, b(a);")
|
||||
expect_compile_error("const fmt::Writer a, b(a);")
|
||||
expect_compile_error("fmt::Writer a, b; b = a;")
|
||||
|
||||
# Formatter is not copyable from a temporary.
|
||||
|
||||
+6
-10
@@ -1359,9 +1359,9 @@ TEST(FormatterTest, FormatExamples) {
|
||||
std::string message = str(Format("The answer is {}") << 42);
|
||||
EXPECT_EQ("The answer is 42", message);
|
||||
|
||||
EXPECT_EQ("42", str(Format("{}") << 42));
|
||||
EXPECT_EQ("42", str(Format(std::string("{}")) << 42));
|
||||
EXPECT_EQ("42", str(Format(Format("{{}}")) << 42));
|
||||
EXPECT_EQ("42", str(format("{}", 42)));
|
||||
EXPECT_EQ("42", str(format(std::string("{}"), 42)));
|
||||
EXPECT_EQ("42", str(format(Format("{{}}"), 42)));
|
||||
|
||||
Writer writer;
|
||||
writer.Format("Current point:\n");
|
||||
@@ -1565,17 +1565,15 @@ TEST(FormatterTest, Examples) {
|
||||
std::string path = "somefile";
|
||||
ReportError("File not found: {0}") << path;
|
||||
|
||||
#if FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES
|
||||
EXPECT_EQ("The answer is 42", str(Format("The answer is {}", 42)));
|
||||
EXPECT_EQ("The answer is 42", str(format("The answer is {}", 42)));
|
||||
EXPECT_THROW_MSG(
|
||||
Format("The answer is {:d}", "forty-two"), FormatError,
|
||||
format("The answer is {:d}", "forty-two"), FormatError,
|
||||
"unknown format code 'd' for string");
|
||||
EXPECT_EQ(L"Cyrillic letter \x42e",
|
||||
str(Format(L"Cyrillic letter {}", L'\x42e')));
|
||||
|
||||
EXPECT_WRITE(stdout,
|
||||
fmt::Print("{}", std::numeric_limits<double>::infinity()), "inf");
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FormatIntTest, Data) {
|
||||
@@ -1644,12 +1642,10 @@ TEST(FormatTest, PrintColored) {
|
||||
|
||||
#endif
|
||||
|
||||
#if FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES
|
||||
TEST(FormatTest, Variadic) {
|
||||
EXPECT_EQ("abc1", str(Format("{}c{}", "ab", 1)));
|
||||
EXPECT_EQ("abc1", str(format("{}c{}", "ab", 1)));
|
||||
EXPECT_EQ(L"abc1", str(Format(L"{}c{}", L"ab", 1)));
|
||||
}
|
||||
#endif // FMT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
template <typename T>
|
||||
std::string str(const T &value) {
|
||||
|
||||
Reference in New Issue
Block a user