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
bdfb50f3
Commit
bdfb50f3
authored
Jun 07, 2017
by
Dean Moldovan
Browse files
Move tests from test_issues.cpp/py into appropriate files
parent
44e9a4e6
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
tests/test_virtual_functions.py
tests/test_virtual_functions.py
+39
-0
No files found.
tests/test_virtual_functions.py
View file @
bdfb50f3
...
@@ -257,3 +257,42 @@ def test_move_support():
...
@@ -257,3 +257,42 @@ def test_move_support():
assert
mv_stats
.
copy_constructions
==
1
assert
mv_stats
.
copy_constructions
==
1
assert
nc_stats
.
move_constructions
>=
0
assert
nc_stats
.
move_constructions
>=
0
assert
mv_stats
.
move_constructions
>=
0
assert
mv_stats
.
move_constructions
>=
0
def
test_dispatch_issue
(
msg
):
"""#159: virtual function dispatch has problems with similar-named functions"""
from
pybind11_tests
import
DispatchIssue
,
dispatch_issue_go
class
PyClass1
(
DispatchIssue
):
def
dispatch
(
self
):
return
"Yay.."
class
PyClass2
(
DispatchIssue
):
def
dispatch
(
self
):
with
pytest
.
raises
(
RuntimeError
)
as
excinfo
:
super
(
PyClass2
,
self
).
dispatch
()
assert
msg
(
excinfo
.
value
)
==
'Tried to call pure virtual function "Base::dispatch"'
p
=
PyClass1
()
return
dispatch_issue_go
(
p
)
b
=
PyClass2
()
assert
dispatch_issue_go
(
b
)
==
"Yay.."
def
test_override_ref
():
"""#392/397: overridding reference-returning functions"""
from
pybind11_tests
import
OverrideTest
o
=
OverrideTest
(
"asdf"
)
# Not allowed (see associated .cpp comment)
# i = o.str_ref()
# assert o.str_ref() == "asdf"
assert
o
.
str_value
()
==
"asdf"
assert
o
.
A_value
().
value
==
"hi"
a
=
o
.
A_ref
()
assert
a
.
value
==
"hi"
a
.
value
=
"bye"
assert
a
.
value
==
"bye"
Prev
1
2
Next
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