@@ -413,37 +413,31 @@ TEST(std_test, format_shared_ptr) {
413413
414414TEST (std_test, format_reference_wrapper) {
415415 int num = 35 ;
416- EXPECT_EQ (" 35 " , fmt::to_string (std::cref (num)));
417- EXPECT_EQ (" 35 " , fmt::to_string (std::ref (num)));
418- EXPECT_EQ (" 35 " , fmt::format (" {}" , std::cref (num)));
419- EXPECT_EQ (" 35 " , fmt::format (" {}" , std::ref (num)));
416+ EXPECT_EQ (fmt::to_string (std::cref (num)), " 35 " );
417+ EXPECT_EQ (fmt::to_string (std::ref (num)), " 35 " );
418+ EXPECT_EQ (fmt::format (" {}" , std::cref (num)), " 35 " );
419+ EXPECT_EQ (fmt::format (" {}" , std::ref (num)), " 35 " );
420420}
421421
422- // Regression test for https://github.com/fmtlib/fmt/issues/4424
423- struct type_with_format_as {
424- int x;
425- };
426-
427- int format_as (const type_with_format_as& t) { return t.x ; }
422+ // Regression test for https://github.com/fmtlib/fmt/issues/4424.
423+ struct type_with_format_as {};
424+ int format_as (type_with_format_as) { return 20 ; }
428425
429426TEST (std_test, format_reference_wrapper_with_format_as) {
430- type_with_format_as t{ 20 } ;
431- EXPECT_EQ (" 20 " , fmt::to_string (std::cref (t)));
432- EXPECT_EQ (" 20 " , fmt::to_string (std::ref (t)));
433- EXPECT_EQ (" 20 " , fmt::format (" {}" , std::cref (t)));
434- EXPECT_EQ (" 20 " , fmt::format (" {}" , std::ref (t)));
427+ type_with_format_as t;
428+ EXPECT_EQ (fmt::to_string (std::cref (t)), " 20 " );
429+ EXPECT_EQ (fmt::to_string (std::ref (t)), " 20 " );
430+ EXPECT_EQ (fmt::format (" {}" , std::cref (t)), " 20 " );
431+ EXPECT_EQ (fmt::format (" {}" , std::ref (t)), " 20 " );
435432}
436433
437- struct type_with_format_as_string {
438- std::string str;
439- };
440-
441- std::string format_as (const type_with_format_as_string& t) { return t.str ; }
434+ struct type_with_format_as_string {};
435+ std::string format_as (type_with_format_as_string) { return " foo" ; }
442436
443437TEST (std_test, format_reference_wrapper_with_format_as_string) {
444- type_with_format_as_string t{ " foo " } ;
445- EXPECT_EQ (" foo " , fmt::to_string (std::cref (t)));
446- EXPECT_EQ (" foo " , fmt::to_string (std::ref (t)));
447- EXPECT_EQ (" foo " , fmt::format (" {}" , std::cref (t)));
448- EXPECT_EQ (" foo " , fmt::format (" {}" , std::ref (t)));
438+ type_with_format_as_string t;
439+ EXPECT_EQ (fmt::to_string (std::cref (t)), " foo " );
440+ EXPECT_EQ (fmt::to_string (std::ref (t)), " foo " );
441+ EXPECT_EQ (fmt::format (" {}" , std::cref (t)), " foo " );
442+ EXPECT_EQ (fmt::format (" {}" , std::ref (t)), " foo " );
449443}
0 commit comments