Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Differential D110494 Diff 375090 libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
Show All 35 Lines | |||||
// template<class Out, class... Args> | // template<class Out, class... Args> | ||||
// Out format_to(Out out, wstring_view fmt, const Args&... args); | // Out format_to(Out out, wstring_view fmt, const Args&... args); | ||||
// template<class Out, class... Args> | // template<class Out, class... Args> | ||||
// Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args); | // Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args); | ||||
// template<class Out, class... Args> | // template<class Out, class... Args> | ||||
// Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args); | // Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args); | ||||
// | // | ||||
// template<class Out> | // template<class Out> | ||||
// Out vformat_to(Out out, string_view fmt, | // Out vformat_to(Out out, string_view fmt, format_args args); | ||||
// format_args_t<type_identity_t<Out>, char> args); | |||||
// template<class Out> | // template<class Out> | ||||
// Out vformat_to(Out out, wstring_view fmt, | // Out vformat_to(Out out, wstring_view fmt, wformat_args args); | ||||
// format_args_t<type_identity_t<Out>, wchar_t> args); | |||||
// template<class Out> | // template<class Out> | ||||
// Out vformat_to(Out out, const locale& loc, string_view fmt, | // Out vformat_to(Out out, const locale& loc, string_view fmt, | ||||
// format_args_t<type_identity_t<Out>, char> args); | // format_args args); | ||||
// template<class Out> | // template<class Out> | ||||
// Out vformat_to(Out out, const locale& loc, wstring_view fmt, | // Out vformat_to(Out out, const locale& loc, wstring_view fmt, | ||||
// format_args_t<type_identity_t<Out>, wchar_t> args); | // wformat_arg args); | ||||
// | // | ||||
// template<class Out> struct format_to_n_result { | // template<class Out> struct format_to_n_result { | ||||
// Out out; | // Out out; | ||||
// iter_difference_t<Out> size; | // iter_difference_t<Out> size; | ||||
// }; | // }; | ||||
// | // | ||||
// template<class Out, class... Args> | // template<class Out, class... Args> | ||||
// format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, | // format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, | ||||
Show All 22 Lines | |||||
#include <format> | #include <format> | ||||
#include <cassert> | #include <cassert> | ||||
#include <iostream> | #include <iostream> | ||||
#include <vector> | #include <vector> | ||||
#include "test_macros.h" | #include "test_macros.h" | ||||
#include "make_string.h" | #include "make_string.h" | ||||
#include "platform_support.h" // locale name macros | #include "platform_support.h" // locale name macros | ||||
#include "format_tests.h" | |||||
#define STR(S) MAKE_STRING(CharT, S) | #define STR(S) MAKE_STRING(CharT, S) | ||||
template <class CharT> | template <class CharT> | ||||
struct numpunct; | struct numpunct; | ||||
template <> | template <> | ||||
struct numpunct<char> : std::numpunct<char> { | struct numpunct<char> : std::numpunct<char> { | ||||
Show All 22 Lines | // *** format *** | ||||
if constexpr (std::same_as<CharT, char>) | if constexpr (std::same_as<CharT, char>) | ||||
if (out != expected) | if (out != expected) | ||||
std::cerr << "\nFormat string " << fmt << "\nExpected output " | std::cerr << "\nFormat string " << fmt << "\nExpected output " | ||||
<< expected << "\nActual output " << out << '\n'; | << expected << "\nActual output " << out << '\n'; | ||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** vformat *** | // *** vformat *** | ||||
{ | { | ||||
std::basic_string<CharT> out = std::vformat( | std::basic_string<CharT> out = | ||||
fmt, std::make_format_args<std::basic_format_context< | std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...)); | ||||
std::back_insert_iterator<std::basic_string<CharT>>, CharT>>( | |||||
args...)); | |||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** format_to *** | // *** format_to *** | ||||
{ | { | ||||
std::basic_string<CharT> out(expected.size(), CharT(' ')); | std::basic_string<CharT> out(expected.size(), CharT(' ')); | ||||
auto it = std::format_to(out.begin(), fmt, args...); | auto it = std::format_to(out.begin(), fmt, args...); | ||||
assert(it == out.end()); | assert(it == out.end()); | ||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** vformat_to *** | // *** vformat_to *** | ||||
{ | { | ||||
std::basic_string<CharT> out(expected.size(), CharT(' ')); | std::basic_string<CharT> out(expected.size(), CharT(' ')); | ||||
auto it = std::vformat_to( | auto it = std::vformat_to(out.begin(), fmt, | ||||
out.begin(), fmt, | std::make_format_args<context_t<CharT>>(args...)); | ||||
std::make_format_args<std::basic_format_context< | |||||
typename std::basic_string<CharT>::iterator, CharT>>(args...)); | |||||
assert(it == out.end()); | assert(it == out.end()); | ||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** format_to_n *** | // *** format_to_n *** | ||||
{ | { | ||||
std::basic_string<CharT> out; | std::basic_string<CharT> out; | ||||
std::format_to_n_result result = | std::format_to_n_result result = | ||||
std::format_to_n(std::back_inserter(out), 1000, fmt, args...); | std::format_to_n(std::back_inserter(out), 1000, fmt, args...); | ||||
Show All 21 Lines | if constexpr (std::same_as<CharT, char>) | ||||
if (out != expected) | if (out != expected) | ||||
std::cerr << "\nFormat string " << fmt << "\nExpected output " | std::cerr << "\nFormat string " << fmt << "\nExpected output " | ||||
<< expected << "\nActual output " << out << '\n'; | << expected << "\nActual output " << out << '\n'; | ||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** vformat *** | // *** vformat *** | ||||
{ | { | ||||
std::basic_string<CharT> out = std::vformat( | std::basic_string<CharT> out = std::vformat( | ||||
loc, fmt, | loc, fmt, std::make_format_args<context_t<CharT>>(args...)); | ||||
std::make_format_args<std::basic_format_context< | |||||
std::back_insert_iterator<std::basic_string<CharT>>, CharT>>( | |||||
args...)); | |||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** format_to *** | // *** format_to *** | ||||
{ | { | ||||
std::basic_string<CharT> out(expected.size(), CharT(' ')); | std::basic_string<CharT> out(expected.size(), CharT(' ')); | ||||
auto it = std::format_to(out.begin(), loc, fmt, args...); | auto it = std::format_to(out.begin(), loc, fmt, args...); | ||||
assert(it == out.end()); | assert(it == out.end()); | ||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** vformat_to *** | // *** vformat_to *** | ||||
{ | { | ||||
std::basic_string<CharT> out(expected.size(), CharT(' ')); | std::basic_string<CharT> out(expected.size(), CharT(' ')); | ||||
auto it = std::vformat_to( | auto it = std::vformat_to(out.begin(), loc, fmt, | ||||
out.begin(), loc, fmt, | std::make_format_args<context_t<CharT>>(args...)); | ||||
std::make_format_args<std::basic_format_context< | |||||
typename std::basic_string<CharT>::iterator, CharT>>(args...)); | |||||
assert(it == out.end()); | assert(it == out.end()); | ||||
assert(out == expected); | assert(out == expected); | ||||
} | } | ||||
// *** format_to_n *** | // *** format_to_n *** | ||||
{ | { | ||||
std::basic_string<CharT> out; | std::basic_string<CharT> out; | ||||
std::format_to_n_result result = | std::format_to_n_result result = | ||||
std::format_to_n(std::back_inserter(out), 1000, loc, fmt, args...); | std::format_to_n(std::back_inserter(out), 1000, loc, fmt, args...); | ||||
▲ Show 20 Lines • Show All 404 Lines • Show Last 20 Lines |