Add std::vector back reference test

This commit is contained in:
William S Fulton 2019-02-18 21:39:09 +00:00
parent f19882ed51
commit 9038a9987d
3 changed files with 25 additions and 0 deletions

View File

@ -647,6 +647,7 @@ CPP_STD_TEST_CASES += \
li_std_pair_using \
li_std_string \
li_std_vector \
li_std_vector_back_reference \
li_std_vector_enum \
li_std_vector_member_var\
li_std_vector_ptr \

View File

@ -0,0 +1,14 @@
%module li_std_vector_back_reference
%include <std_vector.i>
%inline %{
// #include <iostream>
struct Wheel {
int size;
Wheel(int sz = 0) : size(sz) {}
// ~Wheel() { std::cout << "~Wheel" << std::endl; }
};
%}
%template(VectorWheel) std::vector<Wheel>;

View File

@ -0,0 +1,10 @@
from li_std_vector_back_reference import *
def first_element():
v = VectorWheel((Wheel(11), Wheel(22)))
# v will be deleted after exit from this method
return v[0]
size = first_element().size
if size != 11:
raise RuntimeError("Back reference not working {}".format(size))