Add wchar.h for wide char overloads

This commit is contained in:
Victor Zverovich
2021-05-17 20:47:38 -07:00
parent ce14eafc24
commit 0dd91e20d5
8 changed files with 105 additions and 47 deletions

View File

@@ -72,6 +72,7 @@ add_fmt_test(compile-test)
add_fmt_test(printf-test)
add_fmt_test(ranges-test)
add_fmt_test(scan-test)
add_fmt_test(wchar-test)
if (NOT MSVC)
# FMT_ENFORCE_COMPILE_STRING is not supported under MSVC due to compiler bugs.

View File

@@ -590,11 +590,6 @@ TEST(core_test, to_string_view_foreign_strings) {
EXPECT_EQ(type, fmt::detail::type::string_type);
}
TEST(core_test, format_foreign_strings) {
using namespace test_ns;
EXPECT_EQ(fmt::format(test_string<char>("{}"), 42), "42");
}
struct implicitly_convertible_to_string {
operator std::string() const { return "foo"; }
};

View File

@@ -1580,8 +1580,6 @@ TEST(format_test, print) {
EXPECT_WRITE(stdout, fmt::print("Don't {}!", "panic"), "Don't panic!");
EXPECT_WRITE(stderr, fmt::print(stderr, "Don't {}!", "panic"),
"Don't panic!");
// Check that the wide print overload compiles.
if (fmt::detail::const_check(false)) fmt::print(L"test");
}
TEST(format_test, variadic) {

15
test/wchar-test.cc Normal file
View File

@@ -0,0 +1,15 @@
// Formatting library for C++ - formatting library tests
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#include "fmt/wchar.h"
#include "gtest/gtest.h"
TEST(wchar_test, print) {
// Check that the wide print overload compiles.
if (fmt::detail::const_check(false)) fmt::print(L"test");
}