@@ -562,49 +562,6 @@ TEST(locale_test, int_formatter) {
562
562
EXPECT_EQ (fmt::to_string (buf), " 12,345" );
563
563
}
564
564
565
- FMT_BEGIN_NAMESPACE
566
- template <class charT > struct formatter <std::complex<double >, charT> {
567
- private:
568
- detail::dynamic_format_specs<char > specs_;
569
-
570
- public:
571
- FMT_CONSTEXPR typename basic_format_parse_context<charT>::iterator parse (
572
- basic_format_parse_context<charT>& ctx) {
573
- auto end = parse_format_specs (ctx.begin (), ctx.end (), specs_, ctx,
574
- detail::type::float_type);
575
- detail::parse_float_type_spec (specs_);
576
- return end;
577
- }
578
-
579
- template <class FormatContext >
580
- typename FormatContext::iterator format (const std::complex<double >& c,
581
- FormatContext& ctx) const {
582
- auto specs = specs_;
583
- detail::handle_dynamic_spec<detail::precision_checker>(
584
- specs.precision , specs.precision_ref , ctx);
585
- auto fspecs = std::string ();
586
- if (specs.precision > 0 ) fspecs = fmt::format (" .{}" , specs.precision );
587
- if (specs.type == presentation_type::fixed) fspecs += ' f' ;
588
- auto real = fmt::format (ctx.locale ().template get <std::locale>(),
589
- fmt::runtime (" {:" + fspecs + " }" ), c.real ());
590
- auto imag = fmt::format (ctx.locale ().template get <std::locale>(),
591
- fmt::runtime (" {:" + fspecs + " }" ), c.imag ());
592
- auto fill_align_width = std::string ();
593
- if (specs.width > 0 ) fill_align_width = fmt::format (" >{}" , specs.width );
594
- return fmt::format_to (ctx.out (), runtime (" {:" + fill_align_width + " }" ),
595
- c.real () != 0 ? fmt::format (" ({}+{}i)" , real, imag)
596
- : fmt::format (" {}i" , imag));
597
- }
598
- };
599
- FMT_END_NAMESPACE
600
-
601
- TEST (locale_test, complex) {
602
- std::string s = fmt::format (" {}" , std::complex<double >(1 , 2 ));
603
- EXPECT_EQ (s, " (1+2i)" );
604
- EXPECT_EQ (fmt::format (" {:.2f}" , std::complex<double >(1 , 2 )), " (1.00+2.00i)" );
605
- EXPECT_EQ (fmt::format (" {:8}" , std::complex<double >(1 , 2 )), " (1+2i)" );
606
- }
607
-
608
565
TEST (locale_test, chrono_weekday) {
609
566
auto loc = get_locale (" es_ES.UTF-8" , " Spanish_Spain.1252" );
610
567
auto loc_old = std::locale::global (loc);
@@ -625,6 +582,13 @@ TEST(locale_test, sign) {
625
582
EXPECT_EQ (fmt::format (std::locale (), L" {:L}" , -50 ), L" -50" );
626
583
}
627
584
585
+ TEST (std_test_xchar, complex) {
586
+ auto s = fmt::format (L" {}" , std::complex<double >(1 , 2 ));
587
+ EXPECT_EQ (s, L" (1,2)" );
588
+ EXPECT_EQ (fmt::format (L" {:.2f}" , std::complex<double >(1 , 2 )), L" (1.00,2.00)" );
589
+ EXPECT_EQ (fmt::format (L" {:8}" , std::complex<double >(1 , 2 )), L" (1,2) " );
590
+ }
591
+
628
592
TEST (std_test_xchar, optional) {
629
593
# ifdef __cpp_lib_optional
630
594
EXPECT_EQ (fmt::format (L" {}" , std::optional{L' C' }), L" optional(\' C\' )" );
0 commit comments