mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-15 15:00:01 +01:00
Implement println (#3267)
This commit is contained in:
@@ -1778,6 +1778,9 @@ TEST(format_test, print) {
|
||||
EXPECT_WRITE(stdout, fmt::print("Don't {}!", "panic"), "Don't panic!");
|
||||
EXPECT_WRITE(stderr, fmt::print(stderr, "Don't {}!", "panic"),
|
||||
"Don't panic!");
|
||||
EXPECT_WRITE(stdout, fmt::println("Don't {}!", "panic"), "Don't panic!\n");
|
||||
EXPECT_WRITE(stderr, fmt::println(stderr, "Don't {}!", "panic"),
|
||||
"Don't panic!\n");
|
||||
}
|
||||
|
||||
TEST(format_test, variadic) {
|
||||
|
||||
@@ -106,9 +106,17 @@ TEST(ostream_test, empty_custom_output) {
|
||||
}
|
||||
|
||||
TEST(ostream_test, print) {
|
||||
std::ostringstream os;
|
||||
fmt::print(os, "Don't {}!", "panic");
|
||||
EXPECT_EQ("Don't panic!", os.str());
|
||||
{
|
||||
std::ostringstream os;
|
||||
fmt::print(os, "Don't {}!", "panic");
|
||||
EXPECT_EQ("Don't panic!", os.str());
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream os;
|
||||
fmt::println(os, "Don't {}!", "panic");
|
||||
EXPECT_EQ("Don't panic!\n", os.str());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ostream_test, write_to_ostream) {
|
||||
|
||||
@@ -210,7 +210,10 @@ TEST(xchar_test, named_arg_udl) {
|
||||
|
||||
TEST(xchar_test, print) {
|
||||
// Check that the wide print overload compiles.
|
||||
if (fmt::detail::const_check(false)) fmt::print(L"test");
|
||||
if (fmt::detail::const_check(false)) {
|
||||
fmt::print(L"test");
|
||||
fmt::println(L"test");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(xchar_test, join) {
|
||||
@@ -382,9 +385,17 @@ TEST(xchar_test, color) {
|
||||
|
||||
TEST(xchar_test, ostream) {
|
||||
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 409
|
||||
std::wostringstream wos;
|
||||
fmt::print(wos, L"Don't {}!", L"panic");
|
||||
EXPECT_EQ(wos.str(), L"Don't panic!");
|
||||
{
|
||||
std::wostringstream wos;
|
||||
fmt::print(wos, L"Don't {}!", L"panic");
|
||||
EXPECT_EQ(wos.str(), L"Don't panic!");
|
||||
}
|
||||
|
||||
{
|
||||
std::wostringstream wos;
|
||||
fmt::println(wos, L"Don't {}!", L"panic");
|
||||
EXPECT_EQ(wos.str(), L"Don't panic!\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user