Commit 9c739285 authored by Xavier Thompson's avatar Xavier Thompson

Add unit test for cpp iteration over attribute of temporary object

parent ebbc53de
......@@ -11,6 +11,10 @@ cdef extern from "cpp_iterators_simple.h":
double* begin()
double* end()
cdef cppclass HasIterableAttribute:
vector[int] vec
HasIterableAttribute()
def test_vector(py_v):
"""
>>> test_vector([1, 2, 3])
......@@ -177,3 +181,21 @@ def test_iteration_from_function_call():
print(i)
for i in make_vec3():
print(i)
cdef HasIterableAttribute get_has_iterable_attribute():
return HasIterableAttribute()
def test_iteration_from_function_call_attribute():
"""
>>> test_iteration_from_function_call_attribute()
1
2
3
1
2
3
"""
for i in HasIterableAttribute().vec:
print(i)
for i in get_has_iterable_attribute().vec:
print(i)
#include <vector>
class DoublePointerIter {
public:
DoublePointerIter(double* start, int len) : start_(start), len_(len) { }
......@@ -8,3 +10,9 @@ private:
int len_;
};
class HasIterableAttribute {
public:
std::vector<int> vec;
HasIterableAttribute() : vec({1, 2, 3}) {}
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment