Test Event::visit with move-only visitor

This commit is contained in:
kimci86 2025-01-25 18:56:09 +01:00 committed by Chris Thrasher
parent c6df55eed8
commit 37c87ee11e

View File

@ -2,6 +2,7 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <memory>
#include <string_view> #include <string_view>
#include <type_traits> #include <type_traits>
@ -340,5 +341,13 @@ TEST_CASE("[Window] sf::Event")
const sf::Event focusLost = sf::Event::FocusLost{}; const sf::Event focusLost = sf::Event::FocusLost{};
CHECK(focusLost.visit(visitor) == "Other"); CHECK(focusLost.visit(visitor) == "Other");
} }
SECTION("Move-only visitor")
{
auto moveOnlyVisitor = [ptr = std::make_unique<std::string_view>("It works")](const auto&) { return *ptr; };
const sf::Event closed = sf::Event::Closed{};
CHECK(closed.visit(moveOnlyVisitor) == "It works");
}
} }
} }