diff options
author | 2017-02-05 16:01:50 +0100 | |
---|---|---|
committer | 2017-02-05 16:06:06 +0100 | |
commit | ac096aa2a0921efde96b76252dffb119dcf27efc (patch) | |
tree | 2ad9a28a7f6babce8cfcbf5995e3e055ff13ff60 /3rdparty/sol2/test_containers.cpp | |
parent | 29df715138452ee18ba19ec4b07e18c4b3185de7 (diff) |
Update sol2 (nw)
Diffstat (limited to '3rdparty/sol2/test_containers.cpp')
-rw-r--r-- | 3rdparty/sol2/test_containers.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/3rdparty/sol2/test_containers.cpp b/3rdparty/sol2/test_containers.cpp index acb3581440b..224c7ccef5c 100644 --- a/3rdparty/sol2/test_containers.cpp +++ b/3rdparty/sol2/test_containers.cpp @@ -458,3 +458,35 @@ a.readonly_seq = value; )"); REQUIRE_FALSE(result.valid()); } + +TEST_CASE("containers/to_args", "Test that the to_args abstractions works") { + sol::state lua; + lua.open_libraries(); + + lua.script("function f (a, b, c, d) print(a, b, c, d) return a, b, c, d end"); + + sol::function f = lua["f"]; + int a, b, c, d; + + std::vector<int> v2{ 3, 4 }; + sol::tie(a, b, c, d) = f(1, 2, sol::as_args(v2)); + REQUIRE(a == 1); + REQUIRE(b == 2); + REQUIRE(c == 3); + REQUIRE(d == 4); + + std::set<int> v4{ 7, 6, 8, 5 }; + sol::tie(a, b, c, d) = f(sol::as_args(v4)); + REQUIRE(a == 5); + REQUIRE(b == 6); + REQUIRE(c == 7); + REQUIRE(d == 8); + + int v3[] = { 10, 11, 12 }; + sol::tie(a, b, c, d) = f(9, sol::as_args(v3)); + REQUIRE(a == 9); + REQUIRE(b == 10); + REQUIRE(c == 11); + REQUIRE(d == 12); + +} |