Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
Show All 20 Lines | |||||
#include <vector> | #include <vector> | ||||
#include "test_macros.h" | #include "test_macros.h" | ||||
#include "format_tests.h" | #include "format_tests.h" | ||||
auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, | auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, | ||||
std::basic_string<CharT> fmt, | std::basic_string<CharT> fmt, | ||||
const Args&... args) { | const Args&... args) { | ||||
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); | ||||
}; | }; | ||||
auto test_exception = []<class CharT, class... Args>( | auto test_exception = []<class CharT, class... Args>( | ||||
std::string_view what, std::basic_string<CharT> fmt, const Args&... args) { | std::string_view what, std::basic_string<CharT> fmt, const Args&... args) { | ||||
#ifndef TEST_HAS_NO_EXCEPTIONS | #ifndef TEST_HAS_NO_EXCEPTIONS | ||||
try { | try { | ||||
std::vformat( | std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...)); | ||||
fmt, std::make_format_args<std::basic_format_context< | |||||
std::back_insert_iterator<std::basic_string<CharT>>, CharT>>( | |||||
args...)); | |||||
assert(false); | assert(false); | ||||
} catch (std::format_error& e) { | } catch (std::format_error& e) { | ||||
LIBCPP_ASSERT(e.what() == what); | LIBCPP_ASSERT(e.what() == what); | ||||
return; | return; | ||||
} | } | ||||
assert(false); | assert(false); | ||||
#else | #else | ||||
(void)what; | (void)what; | ||||
Show All 13 Lines |