fix xchar support. tests moved/added to xchar-test.cc
This commit is contained in:
parent
a406d8c5be
commit
0045255da1
@ -98,7 +98,7 @@ FMT_END_NAMESPACE
|
|||||||
FMT_BEGIN_NAMESPACE
|
FMT_BEGIN_NAMESPACE
|
||||||
template <typename T, typename Char>
|
template <typename T, typename Char>
|
||||||
struct formatter<std::optional<T>, Char,
|
struct formatter<std::optional<T>, Char,
|
||||||
std::enable_if_t<is_formattable<T>::value>> {
|
std::enable_if_t<is_formattable<T, Char>::value>> {
|
||||||
private:
|
private:
|
||||||
formatter<T, Char> underlying_;
|
formatter<T, Char> underlying_;
|
||||||
static constexpr basic_string_view<Char> optional =
|
static constexpr basic_string_view<Char> optional =
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "fmt/os.h" // fmt::system_category
|
#include "fmt/os.h" // fmt::system_category
|
||||||
#include "fmt/ranges.h"
|
#include "fmt/ranges.h"
|
||||||
#include "fmt/xchar.h"
|
|
||||||
#include "gtest-extra.h" // StartsWith
|
#include "gtest-extra.h" // StartsWith
|
||||||
|
|
||||||
using testing::StartsWith;
|
using testing::StartsWith;
|
||||||
@ -53,7 +52,7 @@ TEST(std_test, thread_id) {
|
|||||||
|
|
||||||
TEST(std_test, optional) {
|
TEST(std_test, optional) {
|
||||||
#ifdef __cpp_lib_optional
|
#ifdef __cpp_lib_optional
|
||||||
EXPECT_EQ(fmt::format(L"{}", std::optional<int>{}), L"none");
|
EXPECT_EQ(fmt::format("{}", std::optional<int>{}), "none");
|
||||||
EXPECT_EQ(fmt::format("{}", std::pair{1, "second"}), "(1, \"second\")");
|
EXPECT_EQ(fmt::format("{}", std::pair{1, "second"}), "(1, \"second\")");
|
||||||
EXPECT_EQ(fmt::format("{}", std::vector{std::optional{1}, std::optional{2},
|
EXPECT_EQ(fmt::format("{}", std::vector{std::optional{1}, std::optional{2},
|
||||||
std::optional{3}}),
|
std::optional{3}}),
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include "fmt/color.h"
|
#include "fmt/color.h"
|
||||||
#include "fmt/ostream.h"
|
#include "fmt/ostream.h"
|
||||||
#include "fmt/ranges.h"
|
#include "fmt/ranges.h"
|
||||||
|
#include "fmt/std.h"
|
||||||
#include "gtest-extra.h" // Contains
|
#include "gtest-extra.h" // Contains
|
||||||
#include "util.h" // get_locale
|
#include "util.h" // get_locale
|
||||||
|
|
||||||
@ -588,4 +589,12 @@ TEST(locale_test, sign) {
|
|||||||
EXPECT_EQ(fmt::format(std::locale(), L"{:L}", -50), L"-50");
|
EXPECT_EQ(fmt::format(std::locale(), L"{:L}", -50), L"-50");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(std_test_xchar, optional) {
|
||||||
|
# ifdef __cpp_lib_optional
|
||||||
|
EXPECT_EQ(fmt::format(L"{}", std::optional{L'C'}), L"optional(\'C\')");
|
||||||
|
EXPECT_EQ(fmt::format(L"{}", std::optional{std::wstring{L"wide string"}}),
|
||||||
|
L"optional(\"wide string\")");
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
|
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user