From 958fd037ab1ddfd1b9a7ea1710975521f3a3087a Mon Sep 17 00:00:00 2001 From: Rohlem Date: Thu, 6 Jul 2017 16:19:44 +0200 Subject: [PATCH] add test case for moving on rvalue-optional push --- test_tables.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test_tables.cpp b/test_tables.cpp index bf1cb870..cb923c93 100644 --- a/test_tables.cpp +++ b/test_tables.cpp @@ -572,3 +572,14 @@ print(tbl[1]) REQUIRE(v1 == 30); REQUIRE(v2 == 40); } + +TEST_CASE("tables/optional-move", "ensure pushing a sol::optional rvalue correctly moves the contained object"){ + sol::state sol_state; + struct move_only{ + int secret_code; + move_only(const move_only&) = delete; + move_only(move_only&&) = default; + }; + sol_state["requires_move"] = sol::optional{move_only{0x4D}}; + REQUIRE(sol_state["requires_move"].get().secret_code == 0x4D); +}