From d59beb708c174fcce92b1f7e0a733ab6b5ef4e5b Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Wed, 21 Jan 2026 08:06:59 +0200 Subject: [PATCH] Add double move coverage --- .../test.cpp | 57 +++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/tests/std/tests/GH_005504_avoid_function_call_wrapping/test.cpp b/tests/std/tests/GH_005504_avoid_function_call_wrapping/test.cpp index 62e1a6ed6db..bd3df479759 100644 --- a/tests/std/tests/GH_005504_avoid_function_call_wrapping/test.cpp +++ b/tests/std/tests/GH_005504_avoid_function_call_wrapping/test.cpp @@ -103,13 +103,23 @@ void test_plain_call(const int expected_copies) { } template -void test_wrapped_call(const int expected_copies) { +void test_wrapped_move_call(const int expected_copies) { InnerWrapper inner{Callable{}}; OuterWrapper outer{move(inner)}; assert(!inner); assert(outer(copy_counter{}) == expected_copies); } +template +void test_wrapped_move_move_call(const int expected_copies) { + InnerWrapper inner{Callable{}}; + MiddleWrapper middle{move(inner)}; + OuterWrapper outer{move(middle)}; + assert(!inner); + assert(!middle); + assert(outer(copy_counter{}) == expected_copies); +} + template void test_wrapped_copy_call(const int expected_copies) { InnerWrapper inner{Callable{}}; @@ -155,25 +165,33 @@ int main() { alloc_checker{1}, test_plain_call, large_callable>(0); // Moves to the same - alloc_checker{0}, test_wrapped_call, function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, function, large_callable>(0); + alloc_checker{0}, test_wrapped_move_call, function, small_callable>(0); + alloc_checker{1}, test_wrapped_move_call, function, large_callable>(0); alloc_checker{0}, test_wrapped_copy_call, function, small_callable>(0); alloc_checker{2}, test_wrapped_copy_call, function, large_callable>(0); - alloc_checker{0}, test_wrapped_call, move_only_function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, move_only_function, large_callable>(0); + alloc_checker{0}, + test_wrapped_move_call, move_only_function, small_callable>(0); + alloc_checker{1}, + test_wrapped_move_call, move_only_function, large_callable>(0); // Abominables and noexcept specifier - alloc_checker{0}, test_wrapped_call, move_only_function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, move_only_function, large_callable>(0); - alloc_checker{0}, test_wrapped_call, move_only_function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, move_only_function, large_callable>(0); + alloc_checker{0}, + test_wrapped_move_call, move_only_function, small_callable>(0); + alloc_checker{1}, + test_wrapped_move_call, move_only_function, large_callable>(0); + alloc_checker{0}, + test_wrapped_move_call, move_only_function, small_callable>(0); + alloc_checker{1}, + test_wrapped_move_call, move_only_function, large_callable>(0); static_assert(!is_constructible_v, move_only_function>); static_assert(!is_constructible_v, move_only_function>); #ifdef __cpp_noexcept_function_type - alloc_checker{0}, test_wrapped_call, move_only_function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, move_only_function, large_callable>(0); + alloc_checker{0}, + test_wrapped_move_call, move_only_function, small_callable>(0); + alloc_checker{1}, + test_wrapped_move_call, move_only_function, large_callable>(0); static_assert(!is_constructible_v, move_only_function>); #endif // defined(__cpp_noexcept_function_type) @@ -182,16 +200,21 @@ int main() { // Moves from function to move_only_function alloc_checker{is_64_bit ? 0 : 1}, - test_wrapped_call, function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, function, large_callable>(0); + test_wrapped_move_call, function, small_callable>(0); + alloc_checker{1}, test_wrapped_move_call, function, large_callable>(0); + + alloc_checker{is_64_bit ? 0 : 1}, test_wrapped_move_move_call, + move_only_function, function, small_callable>(0); + alloc_checker{1}, test_wrapped_move_move_call, move_only_function, + function, large_callable>(0); // Moves from function to abominable move_only_function alloc_checker{is_64_bit ? 0 : 1}, - test_wrapped_call, function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, function, large_callable>(0); + test_wrapped_move_call, function, small_callable>(0); + alloc_checker{1}, test_wrapped_move_call, function, large_callable>(0); alloc_checker{is_64_bit ? 0 : 1}, - test_wrapped_call, function, small_callable>(0); - alloc_checker{1}, test_wrapped_call, function, large_callable>(0); + test_wrapped_move_call, function, small_callable>(0); + alloc_checker{1}, test_wrapped_move_call, function, large_callable>(0); #ifdef __cpp_noexcept_function_type static_assert(!is_constructible_v, function>);