Skip to content

Commit acead03

Browse files
committed
Revert "Add tests for format_to and format_to_n with wchar_t, char16_t, and char32_t"
This reverts commit ada3f1d.
1 parent 1775d0e commit acead03

File tree

1 file changed

+25
-52
lines changed

1 file changed

+25
-52
lines changed

test/xchar-test.cc

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <algorithm>
1111
#include <complex>
1212
#include <cwchar>
13-
#include <string>
1413
#include <vector>
1514

1615
#include "fmt/chrono.h"
@@ -98,23 +97,11 @@ TEST(xchar_test, compile_time_string) {
9897
#endif
9998
}
10099

101-
#define WLIT(x) L##x
102-
#define U16LIT(x) u##x
103-
#define U32LIT(x) U##x
104-
105-
#define DEFINE_FORMAT_TO_TEST(SUITE, NAME, CHAR_TYPE, LIT) \
106-
TEST(SUITE, NAME) { \
107-
auto buf = std::vector<CHAR_TYPE>(); \
108-
fmt::format_to(std::back_inserter(buf), LIT("{}{}"), 42, LIT('\0')); \
109-
auto expected = std::vector<CHAR_TYPE>{LIT('4'), LIT('2'), LIT('\0')}; \
110-
EXPECT_EQ(buf, expected); \
111-
}
112-
113-
DEFINE_FORMAT_TO_TEST(xchar_test, wchar_format_to, wchar_t, WLIT)
114-
DEFINE_FORMAT_TO_TEST(xchar_test, char16_format_to, char16_t, U16LIT)
115-
DEFINE_FORMAT_TO_TEST(xchar_test, char32_format_to, char32_t, U32LIT)
116-
117-
#undef DEFINE_FORMAT_TO_TEST
100+
TEST(xchar_test, format_to) {
101+
auto buf = std::vector<wchar_t>();
102+
fmt::format_to(std::back_inserter(buf), L"{}{}", 42, L'\0');
103+
EXPECT_STREQ(buf.data(), L"42");
104+
}
118105

119106
TEST(xchar_test, compile_time_string_format_to) {
120107
std::wstring ws;
@@ -139,41 +126,27 @@ TEST(xchar_test, format_as) {
139126
EXPECT_EQ(fmt::format(L"{}", test::struct_as_wstring_view()), L"foo");
140127
}
141128

142-
#define DEFINE_FORMAT_TO_N_TEST(SUITE, NAME, CHAR_TYPE, LIT) \
143-
TEST(SUITE, NAME) { \
144-
CHAR_TYPE buffer[4]; \
145-
buffer[3] = LIT('x'); \
146-
auto result = fmt::format_to_n(buffer, 3, LIT("{}"), 12345); \
147-
EXPECT_EQ(5u, result.size); \
148-
EXPECT_EQ(buffer + 3, result.out); \
149-
EXPECT_EQ(std::basic_string<CHAR_TYPE>(LIT("123x")), \
150-
std::basic_string<CHAR_TYPE>(buffer, 4)); \
151-
buffer[0] = LIT('x'); \
152-
buffer[1] = LIT('x'); \
153-
buffer[2] = LIT('x'); \
154-
result = fmt::format_to_n(buffer, 3, LIT("{}"), LIT('A')); \
155-
EXPECT_EQ(1u, result.size); \
156-
EXPECT_EQ(buffer + 1, result.out); \
157-
EXPECT_EQ(std::basic_string<CHAR_TYPE>(LIT("Axxx")), \
158-
std::basic_string<CHAR_TYPE>(buffer, 4)); \
159-
result = fmt::format_to_n(buffer, 3, LIT("{}{} "), LIT('B'), LIT('C')); \
160-
EXPECT_EQ(3u, result.size); \
161-
EXPECT_EQ(buffer + 3, result.out); \
162-
EXPECT_EQ(std::basic_string<CHAR_TYPE>(LIT("BC x")), \
163-
std::basic_string<CHAR_TYPE>(buffer, 4)); \
164-
}
165-
166-
DEFINE_FORMAT_TO_N_TEST(xchar_test, wchar_format_to_n, wchar_t, WLIT)
167-
DEFINE_FORMAT_TO_N_TEST(xchar_test, char16_format_to_n, char16_t, U16LIT)
168-
DEFINE_FORMAT_TO_N_TEST(xchar_test, char32_format_to_n, char32_t, U32LIT)
169-
170-
#undef DEFINE_FORMAT_TO_N_TEST
171-
172-
#undef U32LIT
173-
#undef U16LIT
174-
#undef WLIT
129+
TEST(format_test, wide_format_to_n) {
130+
wchar_t buffer[4];
131+
buffer[3] = L'x';
132+
auto result = fmt::format_to_n(buffer, 3, L"{}", 12345);
133+
EXPECT_EQ(5u, result.size);
134+
EXPECT_EQ(buffer + 3, result.out);
135+
EXPECT_EQ(L"123x", fmt::wstring_view(buffer, 4));
136+
buffer[0] = L'x';
137+
buffer[1] = L'x';
138+
buffer[2] = L'x';
139+
result = fmt::format_to_n(buffer, 3, L"{}", L'A');
140+
EXPECT_EQ(1u, result.size);
141+
EXPECT_EQ(buffer + 1, result.out);
142+
EXPECT_EQ(L"Axxx", fmt::wstring_view(buffer, 4));
143+
result = fmt::format_to_n(buffer, 3, L"{}{} ", L'B', L'C');
144+
EXPECT_EQ(3u, result.size);
145+
EXPECT_EQ(buffer + 3, result.out);
146+
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
147+
}
175148

176-
TEST(xchar_test, wchar_format_to_n_runtime) {
149+
TEST(format_test, wide_format_to_n_runtime) {
177150
wchar_t buffer[4];
178151
buffer[3] = L'x';
179152
auto result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}"), 12345);

0 commit comments

Comments
 (0)