mirror of
https://github.com/fmtlib/fmt.git
synced 2025-08-01 03:34:45 +02:00
Test enabled formatters
This commit is contained in:
@@ -45,6 +45,22 @@ using testing::StrictMock;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool check_enabled_formatter() {
|
||||||
|
static_assert(std::is_default_constructible<fmt::formatter<T>>::value, "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... T>
|
||||||
|
void check_enabled_formatters() {
|
||||||
|
auto dummy = {check_enabled_formatter<T>()...};
|
||||||
|
(void)dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(FormatterTest, TestFormattersEnabled) {
|
||||||
|
check_enabled_formatters<char, signed char, unsigned char>();
|
||||||
|
}
|
||||||
|
|
||||||
// Format value using the standard library.
|
// Format value using the standard library.
|
||||||
template <typename Char, typename T>
|
template <typename Char, typename T>
|
||||||
void std_format(const T &value, std::basic_string<Char> &result) {
|
void std_format(const T &value, std::basic_string<Char> &result) {
|
||||||
@@ -768,7 +784,7 @@ TEST(FormatterTest, ArgErrors) {
|
|||||||
template <int N>
|
template <int N>
|
||||||
struct TestFormat {
|
struct TestFormat {
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
static std::string format(fmt::string_view format_str, const Args & ... args) {
|
static std::string format(fmt::string_view format_str, const Args &... args) {
|
||||||
return TestFormat<N - 1>::format(format_str, N - 1, args...);
|
return TestFormat<N - 1>::format(format_str, N - 1, args...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -776,7 +792,7 @@ struct TestFormat {
|
|||||||
template <>
|
template <>
|
||||||
struct TestFormat<0> {
|
struct TestFormat<0> {
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
static std::string format(fmt::string_view format_str, const Args & ... args) {
|
static std::string format(fmt::string_view format_str, const Args &... args) {
|
||||||
return fmt::format(format_str, args...);
|
return fmt::format(format_str, args...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user