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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2e32985e
Commit
2e32985e
authored
Aug 07, 2015
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for unique_ptr.
parent
fd1adbdf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
tests/run/cpp_smart_ptr.pyx
tests/run/cpp_smart_ptr.pyx
+20
-0
tests/run/cpp_smart_ptr_helper.h
tests/run/cpp_smart_ptr_helper.h
+13
-0
No files found.
tests/run/cpp_smart_ptr.pyx
0 → 100644
View file @
2e32985e
# mode: run
# tag: cpp
from
libcpp.memory
cimport
unique_ptr
,
shared_ptr
cdef
extern
from
"cpp_smart_ptr_helper.h"
:
cdef
cppclass
CountAllocDealloc
:
CountAllocDealloc
(
int
*
,
int
*
)
def
test_unique_ptr
():
"""
>>> test_unique_ptr()
"""
cdef
int
alloc_count
=
0
,
dealloc_count
=
0
cdef
unique_ptr
[
CountAllocDealloc
]
x_ptr
x_ptr
.
reset
(
new
CountAllocDealloc
(
&
alloc_count
,
&
dealloc_count
))
assert
alloc_count
==
1
x_ptr
.
reset
()
assert
alloc_count
==
1
assert
dealloc_count
==
1
tests/run/cpp_smart_ptr_helper.h
0 → 100644
View file @
2e32985e
class
CountAllocDealloc
{
public:
CountAllocDealloc
(
int
*
alloc_count
,
int
*
dealloc_count
)
:
_alloc_count
(
alloc_count
),
_dealloc_count
(
dealloc_count
)
{
(
*
_alloc_count
)
++
;
}
~
CountAllocDealloc
()
{
(
*
_dealloc_count
)
++
;
}
private:
int
*
_alloc_count
;
int
*
_dealloc_count
;
};
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