Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
9c739285
Commit
9c739285
authored
Aug 20, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for cpp iteration over attribute of temporary object
parent
ebbc53de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
tests/run/cpp_iterators.pyx
tests/run/cpp_iterators.pyx
+22
-0
tests/run/cpp_iterators_simple.h
tests/run/cpp_iterators_simple.h
+8
-0
No files found.
tests/run/cpp_iterators.pyx
View file @
9c739285
...
...
@@ -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
)
tests/run/cpp_iterators_simple.h
View file @
9c739285
#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
})
{}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment