}
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
void
test_format_string()
VERIFY( !is_format_string_for("{:{}}", v[0], 1.0f) );
}
-template<typename _CharT>
+template<typename CharT>
void
test_output()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
size_t size = 0;
std::vector<bool> v{true, false};
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
-template<typename _CharT>
+template<typename CharT>
void
test_basic_escapes()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto tab = WIDEN("\t");
res = fdebug(tab);
VERIFY( res == WIDEN(R"('\'')") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_ascii_escapes()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto in = WIDEN("\x10 abcde\x7f\t0123");
res = fdebug(in);
VERIFY( res == WIDEN(R"('a')") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_extended_ascii()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto in = WIDEN("Åëÿ");
res = fdebug(in);
static constexpr bool __test_characters
#if UNICODE_ENC
- = sizeof(_CharT) >= 2;
+ = sizeof(CharT) >= 2;
#else // ISO8859-1
= true;
#endif // UNICODE_ENC
}
}
-template<typename _CharT>
+template<typename CharT>
void
test_unicode_escapes()
{
#if UNICODE_ENC
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto in = WIDEN(
"\u008a" // Cc, Control, Line Tabulation Set,
res = fdebug(in);
VERIFY( res == out );
- if constexpr (sizeof(_CharT) >= 2)
+ if constexpr (sizeof(CharT) >= 2)
{
res = fdebug(in[0]);
VERIFY( res == WIDEN(R"('\u{8a}')") );
VERIFY( res == WIDEN(R"('\u{2029}')") );
}
- if constexpr (sizeof(_CharT) >= 4)
+ if constexpr (sizeof(CharT) >= 4)
{
res = fdebug(in[5]);
VERIFY( res == WIDEN("'\U0001f984'") );
#endif // UNICODE_ENC
}
-template<typename _CharT>
+template<typename CharT>
void
test_grapheme_extend()
{
#if UNICODE_ENC
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto vin = WIDEN("o\u0302\u0323");
res = fdebug(vin);
VERIFY( res == WIDEN("\"o\u0302\u0323\"") );
- std::basic_string_view<_CharT> in = WIDEN("\t\u0302\u0323");
+ std::basic_string_view<CharT> in = WIDEN("\t\u0302\u0323");
res = fdebug(in);
VERIFY( res == WIDEN(R"("\t\u{302}\u{323}")") );
res = fdebug(in.substr(1));
VERIFY( res == WIDEN(R"("\u{302}\u{323}")") );
- if constexpr (sizeof(_CharT) >= 2)
+ if constexpr (sizeof(CharT) >= 2)
{
res = fdebug(in[1]);
VERIFY( res == WIDEN(R"('\u{302}')") );
#endif // UNICODE_ENC
}
-template<typename _CharT>
+template<typename CharT>
void
test_replacement_char()
{
#if UNICODE_ENC
- std::basic_string<_CharT> repl = WIDEN("\uFFFD");
- std::basic_string<_CharT> res = fdebug(repl);
+ std::basic_string<CharT> repl = WIDEN("\uFFFD");
+ std::basic_string<CharT> res = fdebug(repl);
VERIFY( res == WIDEN("\"\uFFFD\"") );
repl = WIDEN("\uFFFD\uFFFD");
#endif // UNICODE_ENC
}
-template<typename _CharT>
+template<typename CharT>
void
test_fill()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
- std::basic_string_view<_CharT> in = WIDEN("a\t\x10\u00ad");
+ std::basic_string_view<CharT> in = WIDEN("a\t\x10\u00ad");
res = std::format(WIDEN("{:10?}"), in.substr(0, 1));
VERIFY( res == WIDEN(R"("a" )") );
VERIFY( res == WIDEN(R"(="\u{ad}"=)") );
// width is 2
- std::basic_string_view<_CharT> in2 = WIDEN("\u1100");
+ std::basic_string_view<CharT> in2 = WIDEN("\u1100");
res = std::format(WIDEN("{:*^10?}"), in2);
VERIFY( res == WIDEN("***\"\u1100\"***") );
- if constexpr (sizeof(_CharT) >= 2)
+ if constexpr (sizeof(CharT) >= 2)
{
res = std::format(WIDEN("{:=^10?}"), in[3]);
VERIFY( res == WIDEN(R"(='\u{ad}'=)") );
#endif // UNICODE_ENC
}
-template<typename _CharT>
+template<typename CharT>
void
test_prec()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
// with ? escpaed presentation is copied to ouput, same as source
- std::basic_string_view<_CharT> in = WIDEN("a\t\x10\u00ad");
+ std::basic_string_view<CharT> in = WIDEN("a\t\x10\u00ad");
res = std::format(WIDEN("{:.2?}"), in.substr(0, 1));
VERIFY( res == WIDEN(R"("a)") );
res = std::format(WIDEN("{:.10?}"), in.substr(3));
VERIFY( res == WIDEN(R"("\u{ad}")") );
- std::basic_string_view<_CharT> in2 = WIDEN("\u1100");
+ std::basic_string_view<CharT> in2 = WIDEN("\u1100");
res = std::format(WIDEN("{:.3?}"), in2);
VERIFY( res == WIDEN("\"\u1100") );
#endif // UNICODE_ENC
std::formatter<T, CharT> under;
};
-template<typename _CharT, typename StrT>
+template<typename CharT, typename StrT>
void
test_formatter_str()
{
- _CharT buf[]{ 'a', 'b', 'c', 0 };
+ CharT buf[]{ 'a', 'b', 'c', 0 };
DebugWrapper<StrT> in{ buf };
- std::basic_string<_CharT> res = std::format(WIDEN("{:?}"), in );
+ std::basic_string<CharT> res = std::format(WIDEN("{:?}"), in );
VERIFY( res == WIDEN(R"("abc")") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_formatter_arr()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
- DebugWrapper<_CharT[3]> in3{ 'a', 'b', 'c' };
+ DebugWrapper<CharT[3]> in3{ 'a', 'b', 'c' };
res = std::format(WIDEN("{:?}"), in3 );
VERIFY( res == WIDEN(R"("abc")") );
// We print all characters, including null-terminator
- DebugWrapper<_CharT[4]> in4{ 'a', 'b', 'c', 0 };
+ DebugWrapper<CharT[4]> in4{ 'a', 'b', 'c', 0 };
res = std::format(WIDEN("{:?}"), in4 );
VERIFY( res == WIDEN(R"("abc\u{0}")") );
}
-template<typename _CharT, typename SrcT>
+template<typename CharT, typename SrcT>
void
test_formatter_char()
{
DebugWrapper<SrcT> in{ 'a' };
- std::basic_string<_CharT> res = std::format(WIDEN("{:?}"), in);
+ std::basic_string<CharT> res = std::format(WIDEN("{:?}"), in);
VERIFY( res == WIDEN(R"('a')") );
}
}
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
template<template<typename Tp> class Adaptor>
void
constexpr auto std::format_kind<NotFormattableCont<T>>
= std::range_format::disabled;
-template<typename _CharT,
+template<typename CharT,
template<typename Tp, typename Cont = std::vector<Tp>> class Adaptor>
void
test_output()
{
const std::vector<int> v{3, 2, 1};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
Adaptor<int, std::vector<int>> q(std::from_range, v);
res = std::format(WIDEN("{}"), q);
VERIFY( res == WIDEN("==[0x03, 0x02, 0x01]===") );
// Sequence output is always used
- Adaptor<_CharT, std::basic_string<_CharT>> qs(
+ Adaptor<CharT, std::basic_string<CharT>> qs(
std::from_range,
- std::basic_string_view<_CharT>(WIDEN("321")));
+ std::basic_string_view<CharT>(WIDEN("321")));
res = std::format(WIDEN("{}"), qs);
VERIFY( res == WIDEN("['3', '2', '1']") );
res = std::format(WIDEN("{}"), mq);
VERIFY( res == WIDEN("[3, 2, 1]") );
- static_assert(!std::formattable<const Adaptor<MutFormat>, _CharT>);
+ static_assert(!std::formattable<const Adaptor<MutFormat>, CharT>);
- static_assert(!std::formattable<Adaptor<NoFormat>, _CharT>);
- static_assert(!std::formattable<const Adaptor<NoFormat>, _CharT>);
+ static_assert(!std::formattable<Adaptor<NoFormat>, CharT>);
+ static_assert(!std::formattable<const Adaptor<NoFormat>, CharT>);
// Formatter check if container is formattable, not container elements.
- static_assert(!std::formattable<Adaptor<int, NotFormattableCont<int>>, _CharT>);
+ static_assert(!std::formattable<Adaptor<int, NotFormattableCont<int>>, CharT>);
}
template<template<typename Tp, typename Cont = std::vector<Tp>> class Adaptor>
static_assert(!std::formattable<Adaptor<int>, char32_t>);
}
-template<typename _CharT>
+template<typename CharT>
void
test_compare()
{
const std::vector<int> v{3, 2, 1};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
std::priority_queue<int, std::vector<int>, std::greater<>> q(
std::from_range, v);
#include <vector>
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
template<typename T,
template<typename, typename> class Formatter = std::range_formatter>
{
constexpr formatter() noexcept
{
- using _CharT = CharT;
_formatter.set_brackets(WIDEN("<"), WIDEN(">"));
_formatter.set_separator(WIDEN("; "));
}
Formatter<T, CharT> _formatter;
};
-template<typename _CharT, template<typename, typename> class Formatter>
+template<typename CharT, template<typename, typename> class Formatter>
void
test_default()
{
MyVector<int, Formatter> vec{1, 2, 3};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{}"), vec);
VERIFY( res == WIDEN("<1; 2; 3>") );
VERIFY( res == WIDEN("< +1 ; +2 ; +3 >") );
}
-template<typename _CharT, template<typename, typename> class Formatter>
+template<typename CharT, template<typename, typename> class Formatter>
void
test_override()
{
- MyVector<_CharT, Formatter> vc{'a', 'b', 'c', 'd'};
+ MyVector<CharT, Formatter> vc{'a', 'b', 'c', 'd'};
MyVector<std::pair<int, int>, Formatter> vp{{1, 11}, {2, 21}};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:s}"), vc);
VERIFY( res == WIDEN("abcd") );
}
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
void
test_format_string()
VERIFY( !is_format_string_for("{:{}m}", std::vector<std::pair<int, int>>(), 1.0f) );
}
-template<typename _CharT, typename Range>
+template<typename CharT, typename Range>
void test_output(bool mapIsDefault)
{
- using Sv = std::basic_string_view<_CharT>;
+ using Sv = std::basic_string_view<CharT>;
using Pt = std::ranges::range_value_t<Range>;
using Ft = std::remove_cvref_t<std::tuple_element_t<0, Pt>>;
using St = std::remove_cvref_t<std::tuple_element_t<1, Pt>>;
return Range(s.data(), s.data() + s.size());
};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
size_t size = 0;
Ft f1[]{1, 2, 3};
}
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
-template<typename _CharT, typename Range, typename Storage>
+template<typename CharT, typename Range, typename Storage>
void test_output()
{
- using Sv = std::basic_string_view<_CharT>;
+ using Sv = std::basic_string_view<CharT>;
using T = std::ranges::range_value_t<Range>;
auto makeRange = [](Storage& s) -> Range {
if constexpr (std::is_same_v<std::remove_cvref_t<Range>, Storage>)
std::ranges::data(s) + std::ranges::size(s));
};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
size_t size = 0;
Storage v1{1, 2, 3};
}
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
void
test_format_string()
template<typename Range>
void test_output()
{
- using _CharT = std::ranges::range_value_t<Range>;
- auto makeRange = [](std::basic_string<_CharT>& s) {
+ using CharT = std::ranges::range_value_t<Range>;
+ auto makeRange = [](std::basic_string<CharT>& s) {
return Range(s.data(), s.data() + s.size());
};
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
size_t size = 0;
- std::basic_string<_CharT> s1 = WIDEN("abcd");
+ std::basic_string<CharT> s1 = WIDEN("abcd");
res = std::format(WIDEN("{}"), makeRange(s1));
VERIFY( res == WIDEN("['a', 'b', 'c', 'd']") );
res = std::format(WIDEN("{:=^8s}"), makeRange(s1));
VERIFY( res == WIDEN("==abcd==") );
- std::basic_string<_CharT> s2(512, static_cast<_CharT>('a'));
+ std::basic_string<CharT> s2(512, static_cast<CharT>('a'));
res = std::format(WIDEN("{:=^8s}"), makeRange(s2));
VERIFY( res == s2 );
}
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
void
test_format_string()
VERIFY( !is_format_string_for("{:{}}", std::tuple<>(), 1.0f) );
}
-template<typename _CharT>
+template<typename CharT>
void test_multi()
{
- using Sv = std::basic_string_view<_CharT>;
- using Str = std::basic_string<_CharT>;
+ using Sv = std::basic_string_view<CharT>;
+ using Str = std::basic_string<CharT>;
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
std::size_t size = 0;
std::tuple<int, Str, float> t1(1, WIDEN("test"), 2.1);
}
-template<typename _CharT, typename Tuple>
+template<typename CharT, typename Tuple>
void test_empty()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
Tuple e1;
res = std::format(WIDEN("{}"), e1);
VERIFY( res == WIDEN(R"(^^^^())") );
}
-template<typename _CharT, typename Pair>
+template<typename CharT, typename Pair>
void test_pair()
{
using Ft = std::remove_cvref_t<std::tuple_element_t<0, Pair>>;
using St = std::remove_cvref_t<std::tuple_element_t<1, Pair>>;
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
Ft f1 = 1;
St s1 = WIDEN("abc");
{
constexpr formatter() noexcept
{
- using _CharT = CharT;
_formatter.set_brackets(WIDEN("<"), WIDEN(">"));
_formatter.set_separator(WIDEN("; "));
}
std::formatter<Pair, CharT> _formatter;
};
-template<typename _CharT, template<typename, typename> class PairT>
+template<typename CharT, template<typename, typename> class PairT>
void test_custom()
{
- std::basic_string<_CharT> res;
- MyPair<PairT<int, const _CharT*>> c1(1, WIDEN("abc"));
+ std::basic_string<CharT> res;
+ MyPair<PairT<int, const CharT*>> c1(1, WIDEN("abc"));
res = std::format(WIDEN("{}"), c1);
VERIFY( res == WIDEN(R"(<1; "abc">)") );
using namespace std::chrono;
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
template<typename CharT, typename T>
void
}
}
-template<typename T, typename _CharT>
-void verify(const T& t, std::basic_string_view<_CharT> str)
+template<typename T, typename CharT>
+void verify(const T& t, std::basic_string_view<CharT> str)
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{}"), t);
VERIFY( res == str );
- std::basic_stringstream<_CharT> os;
+ std::basic_stringstream<CharT> os;
os << t;
res = std::move(os).str();
VERIFY( res == str );
void verify(const T& t, const CharT* str)
{ verify(t, std::basic_string_view<CharT>(str)); }
-template<typename _CharT>
+template<typename CharT>
void
test_padding()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:5}"), day(2));
VERIFY( res == WIDEN("02 ") );
friend auto operator<=>(Rep, Rep) = default;
- template<typename _CharT>
- friend std::basic_ostream<_CharT>&
- operator<<(std::basic_ostream<_CharT>& os, const Rep& t)
+ template<typename CharT>
+ friend std::basic_ostream<CharT>&
+ operator<<(std::basic_ostream<CharT>& os, const Rep& t)
{ return os << t.val << WIDEN("[via <<]"); }
long val;
: std::numeric_limits<long>
{ };
-template<typename Ret, typename _CharT>
-struct std::formatter<Rep<Ret>, _CharT>
- : std::formatter<long, _CharT>
+template<typename Ret, typename CharT>
+struct std::formatter<Rep<Ret>, CharT>
+ : std::formatter<long, CharT>
{
template<typename Out>
- typename std::basic_format_context<Out, _CharT>::iterator
- format(const Rep<Ret>& t, std::basic_format_context<Out, _CharT>& ctx) const
+ typename std::basic_format_context<Out, CharT>::iterator
+ format(const Rep<Ret>& t, std::basic_format_context<Out, CharT>& ctx) const
{
- constexpr std::basic_string_view<_CharT> suffix = WIDEN("[via format]");
- auto out = std::formatter<long, _CharT>::format(t.val, ctx);
+ constexpr std::basic_string_view<CharT> suffix = WIDEN("[via format]");
+ auto out = std::formatter<long, CharT>::format(t.val, ctx);
return std::ranges::copy(suffix, out).out;
}
};
using deciseconds = duration<seconds::rep, std::deci>;
-template<typename _CharT>
+template<typename CharT>
void
test_duration()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const milliseconds di(40);
verify( di, WIDEN("40ms") );
VERIFY( res == WIDEN(" -40ms") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_duration_fp()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const duration<double> df(11.22);
verify( df, WIDEN("11.22s") );
VERIFY( res == WIDEN("11.22s") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_duration_cust()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const duration<char, std::ratio<1, 10>> charRep(123);
verify( charRep, WIDEN("123ds") );
return hh_mm_ss<Dur>(duration_cast<Dur>(d));
}
-template<typename _CharT>
+template<typename CharT>
void
test_hh_mm_ss()
{
WIDEN("-14322:24:54.111222333") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_hh_mm_ss_fp()
{
WIDEN("-22:24:54") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_hh_mm_ss_cust()
{
test_hh_mm_ss_cust<CharT>();
}
-template<typename _CharT>
+template<typename CharT>
void
test_day()
{
verify( day(255), WIDEN("255 is not a valid day") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_month()
{
verify( month(255), WIDEN("255 is not a valid month") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_year()
{
verify( year(32767), WIDEN( "32767") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_weekday()
{
verify( weekday(255), WIDEN("255 is not a valid weekday") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_weekday_indexed()
{
verify( weekday(32)[7], WIDEN("32 is not a valid weekday[7 is not a valid index]") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_weekday_last()
{
verify( weekday(9)[last], WIDEN("9 is not a valid weekday[last]") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_month_day()
{
verify( month(13)/32, WIDEN("13 is not a valid month/32 is not a valid day") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_month_day_last()
{
verify( month(14)/last, WIDEN("14 is not a valid month/last") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_month_weekday()
{
WIDEN("13 is not a valid month/130 is not a valid weekday[0 is not a valid index]") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_month_weekday_last()
{
WIDEN("13 is not a valid month/10 is not a valid weekday[last]") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_year_month()
{
WIDEN("-32768 is not a valid year/0 is not a valid month") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_year_month_day()
{
WIDEN("-32768-14-55 is not a valid date") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_year_month_last()
{
WIDEN("-32768 is not a valid year/0 is not a valid month/last") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_year_month_weekday()
{
WIDEN("-32768 is not a valid year/13 is not a valid month/130 is not a valid weekday[0 is not a valid index]") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_year_month_weekday_last()
{
using decadays = duration<days::rep, std::ratio_multiply<std::deca, days::period>>;
using kilodays = duration<days::rep, std::ratio_multiply<std::kilo, days::period>>;
-template<typename _CharT, typename Clock>
+template<typename CharT, typename Clock>
void
test_time_point(bool daysAsTime)
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto lt = local_days(2024y/March/22) + 13h + 24min + 54s + 111222333ns;
- auto strip_time = [daysAsTime](std::basic_string_view<_CharT> sv)
+ auto strip_time = [daysAsTime](std::basic_string_view<CharT> sv)
{ return daysAsTime ? sv : sv.substr(0, 10); };
verify( wall_cast<Clock, nanoseconds>(lt),
strip_time(WIDEN("2022-01-08 00:00:00")) );
}
-template<typename _CharT>
+template<typename CharT>
void
test_leap_second()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const auto st = sys_days(2012y/June/30) + 23h + 59min + 59s + 111222333ns;
auto tp = clock_cast<utc_clock>(st);
make_zoned(const sys_time<Dur2>& st, const time_zone* tz)
{ return zoned_time<Dur>(tz, floor<Dur>(st)); }
-template<typename _CharT>
+template<typename CharT>
void
test_zoned_time()
{
local_fmt(const local_time<Dur2>& lt, std::string* zone)
{ return local_time_format(floor<Dur>(lt), zone); }
-template<typename _CharT>
+template<typename CharT>
void
test_local_time_format()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
std::string abbrev = "Zone";
const auto lt = local_days(2024y/March/22) + 13h + 24min + 54s + 111222333ns;
}
#if _GLIBCXX_USE_CXX11_ABI || !_GLIBCXX_USE_DUAL_ABI
-template<typename _CharT>
+template<typename CharT>
void
test_sys_info()
{
15min,
"Zone"
};
- const std::basic_string_view<_CharT> txt
+ const std::basic_string_view<CharT> txt
= WIDEN("[2024-03-22 02:00:00,2025-04-11 23:15:10,02:13:04,15min,Zone]");
verify( si, txt );
- std::basic_string<_CharT> res;
- std::basic_string_view<_CharT> sv;
+ std::basic_string<CharT> res;
+ std::basic_string_view<CharT> sv;
sv = res = std::format(WIDEN("{:65}"), si);
VERIFY( sv.ends_with(WIDEN(" ")) );
VERIFY( sv == txt );
}
-template<typename _CharT>
+template<typename CharT>
void test_local_info()
{
- using String = std::basic_string<_CharT>;
- using StringView = std::basic_string_view<_CharT>;
+ using String = std::basic_string<CharT>;
+ using StringView = std::basic_string_view<CharT>;
const sys_info s1
{
#include <testsuite_hooks.h>
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
-template<typename _CharT>
+template<typename CharT>
void
test_from_format_string()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
using namespace std::chrono_literals;
auto date = 2025y/std::chrono::May/05d;
VERIFY( res == WIDEN("====2025-05-05\U0001f921====") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_formatted_value()
{
// Custom time_put facet which returns Ideographic Telegraph Symbol
// for given month for Om.
- struct TimePut : std::time_put<_CharT>
+ struct TimePut : std::time_put<CharT>
{
- using iter_type = std::time_put<_CharT>::iter_type;
- using char_type = std::time_put<_CharT>::char_type;
+ using iter_type = std::time_put<CharT>::iter_type;
+ using char_type = std::time_put<CharT>::char_type;
iter_type
do_put(iter_type out, std::ios_base& io, char_type fill, const tm* t,
char format, char modifier) const override
{
if (format != 'm' && modifier != 'm')
- return std::time_put<_CharT>::do_put(out, io, fill, t, format, modifier);
- std::basic_string_view<_CharT> str;
+ return std::time_put<CharT>::do_put(out, io, fill, t, format, modifier);
+ std::basic_string_view<CharT> str;
switch (t->tm_mon)
{
case 0:
};
const std::locale loc(std::locale::classic(), new TimePut);
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(loc, WIDEN("{:<1L%Om}"), std::chrono::January);
VERIFY( res == WIDEN("\u32C0") );
#include <testsuite_hooks.h>
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
using namespace std::chrono;
-template<typename _CharT>
+template<typename CharT>
void
test_year()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:%Y}"), year(0));
VERIFY( res == WIDEN("0000") );
VERIFY( res == WIDEN("01") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_month()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:%m}"), month(5));
VERIFY( res == WIDEN("05") );
VERIFY( res == WIDEN("254") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_day()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:%d}"), day(3));
VERIFY( res == WIDEN("03") );
VERIFY( res == WIDEN("214") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_date()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:%F}"), year(-22)/month(10)/day(20));
VERIFY( res == WIDEN("-0022-10-20") );
VERIFY( res == WIDEN("220/100/00") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_weekday()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:%w}"), weekday(0));
VERIFY( res == WIDEN("0") );
VERIFY( res == WIDEN("202") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_hour()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
res = std::format(WIDEN("{:%H}"), 0h + 5min + 6s);
VERIFY( res == WIDEN("00") );
using namespace std::chrono;
#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S)
-#define WIDEN(S) WIDEN_(_CharT, S)
+#define WIDEN(S) WIDEN_(CharT, S)
-template<typename _CharT>
+template<typename CharT>
void
test_empty()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const duration<double> d(33.111222);
res = std::format(WIDEN("{:.3}"), d);
VERIFY( res == WIDEN("3.31112e+10ns") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_Q()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
const duration<double> d(7.111222);
res = std::format(WIDEN("{:.3%Q}"), d);
VERIFY( res == WIDEN("7111222000") );
}
-template<typename _CharT>
+template<typename CharT>
void
test_S()
{
- std::basic_string<_CharT> res;
+ std::basic_string<CharT> res;
// Precision is ignored, but period affects output
const duration<double> d(5.111222);