mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Fixes #394
This commit is contained in:
parent
28fff10637
commit
814562260d
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2017-04-07 01:10:42.173645 UTC
|
||||
// This header was generated with sol v2.16.0 (revision e856abc)
|
||||
// Generated 2017-04-08 12:25:20.970713 UTC
|
||||
// This header was generated with sol v2.17.0 (revision 28fff10)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -11783,11 +11783,11 @@ namespace sol {
|
|||
#endif
|
||||
using std::begin;
|
||||
auto it = begin(src);
|
||||
--k;
|
||||
if (k == src.size()) {
|
||||
real_add_call_push(std::integral_constant<bool, detail::has_push_back<T>::value>(), L, src, 1);
|
||||
return 0;
|
||||
}
|
||||
--k;
|
||||
std::advance(it, k);
|
||||
*it = stack::get<V>(L, 3);
|
||||
return 0;
|
||||
|
|
|
@ -239,11 +239,11 @@ namespace sol {
|
|||
#endif
|
||||
using std::begin;
|
||||
auto it = begin(src);
|
||||
--k;
|
||||
if (k == src.size()) {
|
||||
real_add_call_push(std::integral_constant<bool, detail::has_push_back<T>::value>(), L, src, 1);
|
||||
return 0;
|
||||
}
|
||||
--k;
|
||||
std::advance(it, k);
|
||||
*it = stack::get<V>(L, 3);
|
||||
return 0;
|
||||
|
|
|
@ -522,3 +522,39 @@ end
|
|||
REQUIRE(ct.x == 20);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/append-idiom", "ensure the append-idiom works as intended") {
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base);
|
||||
lua.script(
|
||||
R"(
|
||||
function f_fill(vec)
|
||||
print("#vec in lua: " .. #vec)
|
||||
for k = 1, #vec do
|
||||
vec[k] = k
|
||||
end
|
||||
print("#vec in lua: " .. #vec)
|
||||
end
|
||||
function f_append(vec)
|
||||
print("#vec in lua: " .. #vec)
|
||||
vec[#vec] = -10456407
|
||||
vec[#vec + 1] = -54
|
||||
print("#vec in lua: " .. #vec)
|
||||
end
|
||||
)");
|
||||
std::vector<int> fill_cmp{ 1, 2, 3 };
|
||||
std::vector<int> append_cmp{ -1, -1, -10456407, -54 };
|
||||
|
||||
std::vector<int> vec1{ -1, -1, -1 };
|
||||
std::vector<int> vec2{ -1, -1, -1 };
|
||||
|
||||
REQUIRE(vec1.size() == 3);
|
||||
lua["f_fill"](vec1);
|
||||
REQUIRE(vec1.size() == 3);
|
||||
REQUIRE(vec1 == fill_cmp);
|
||||
|
||||
REQUIRE(vec2.size() == 3);
|
||||
lua["f_append"](vec2);
|
||||
REQUIRE(vec2.size() == 4);
|
||||
REQUIRE(vec2 == append_cmp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user