Make lua binding for std::vector (#164)

* Make LuaImplQueryArg impl for std::vector

* Fix shadowed argument

* Make unit tests

* Bugfix

* Bugfix, for real this time

* We didn't need these tests anyway

* Revert "We didn't need these tests anyway"

This reverts commit be88d4496a9cf62beb4d3ce1f30825589a4bacb2.

* Add change to changelog

* Update ChangeLog.md

* Bugfix & use CallOnExit to pop stack
This commit is contained in:
S6066
2018-06-17 19:04:15 +02:00
committed by Jérôme Leclercq
parent 858d0da5f2
commit da044bd21c
3 changed files with 60 additions and 0 deletions

View File

@@ -183,5 +183,34 @@ SCENARIO("LuaState", "[LUA][LUASTATE]")
CHECK(luaInstance.ToNumber(1) == Approx(-4.09).margin(0.1));
}
}
WHEN("We push a std::vector locally")
{
std::vector<int> vec { 1, 5, -8, 6, -4 };
luaInstance.Push(std::vector<int> { vec });
THEN("We can retrieve it with correct values")
{
int index = 1;
std::vector<int> otherVec = luaInstance.Check<std::vector<int>>(&index);
for (std::size_t i {}; i < otherVec.size(); ++i)
CHECK(otherVec[i] == vec[i]);
}
}
WHEN("We push a std::vector globally")
{
std::vector<int> vec { 1, 5, -8, 6, -4 };
luaInstance.PushGlobal("vector", std::vector<int> { vec });
THEN("We can retrieve it with correct values")
{
std::vector<int> otherVec = luaInstance.CheckGlobal<std::vector<int>>("vector");
for (std::size_t i {}; i < otherVec.size(); ++i)
CHECK(otherVec[i] == vec[i]);
}
}
}
}