Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
a72e5f0c
Commit
a72e5f0c
authored
Jan 15, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Inserting additional assert to ensure a returned unique_ptr is always a new Python instance.
parent
ec86f100
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
tests/test_classh_wip.py
tests/test_classh_wip.py
+6
-0
No files found.
tests/test_classh_wip.py
View file @
a72e5f0c
...
...
@@ -70,7 +70,13 @@ def test_pass_unique_ptr_disowns(pass_mpty, argm, rtrn):
def
test_unique_ptr_roundtrip
(
num_round_trips
=
1000
):
# Multiple roundtrips to stress-test instance registration/deregistration.
recycled
=
m
.
mpty
(
"passenger"
)
for
_
in
range
(
num_round_trips
):
id_orig
=
id
(
recycled
)
recycled
=
m
.
unique_ptr_roundtrip
(
recycled
)
assert
m
.
get_mtxt
(
recycled
)
==
"passenger"
id_rtrn
=
id
(
recycled
)
# Ensure the returned object is a different Python instance.
assert
id_rtrn
!=
id_orig
id_orig
=
id_rtrn
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