Skip to content

Commit f07d37d

Browse files
committed
Merge incomplete type test into format-test.cc
1 parent 3ba09ef commit f07d37d

File tree

3 files changed

+30
-42
lines changed

3 files changed

+30
-42
lines changed

test/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ add_fmt_test(assert-test)
5353
add_fmt_test(chrono-test)
5454
add_fmt_test(color-test)
5555
add_fmt_test(gtest-extra-test)
56-
add_fmt_test(incomplete-type-test)
5756
add_fmt_test(format-test mock-allocator.h)
5857
if (MSVC)
5958
target_compile_options(format-test PRIVATE /bigobj)

test/format-test.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,3 +2586,33 @@ TEST(base_test, format_byte) {
25862586
EXPECT_EQ(s, "42");
25872587
}
25882588
#endif
2589+
2590+
// Only defined after the test case.
2591+
struct incomplete_type;
2592+
extern const incomplete_type& external_instance;
2593+
2594+
FMT_BEGIN_NAMESPACE
2595+
2596+
template <> struct formatter<incomplete_type> : formatter<int> {
2597+
auto format(const incomplete_type& x, context& ctx) const
2598+
-> decltype(ctx.out());
2599+
};
2600+
2601+
FMT_END_NAMESPACE
2602+
2603+
TEST(incomplete_type_test, format) {
2604+
EXPECT_EQ(fmt::format("{}", external_instance), fmt::format("{}", 42));
2605+
EXPECT_EQ(fmt::format("{:4}", external_instance), fmt::format("{:4}", 42));
2606+
}
2607+
2608+
struct incomplete_type {
2609+
int i;
2610+
};
2611+
2612+
const incomplete_type& external_instance{42};
2613+
2614+
auto fmt::formatter<incomplete_type>::format(const incomplete_type& x,
2615+
fmt::context& ctx) const
2616+
-> decltype(ctx.out()) {
2617+
return fmt::formatter<int>::format(x.i, ctx);
2618+
}

test/incomplete-type-test.cc

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)