Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
2ea4b8e8
Commit
2ea4b8e8
authored
Sep 04, 2016
by
Wenzel Jakob
Committed by
GitHub
Sep 04, 2016
Browse files
Merge pull request #381 from jagerman/tests-self-registering
Make test initialization self-registering
parents
06d8de11
52f4be89
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
tests/test_pickling.cpp
tests/test_pickling.cpp
+2
-2
tests/test_python_types.cpp
tests/test_python_types.cpp
+2
-2
tests/test_sequences_and_iterators.cpp
tests/test_sequences_and_iterators.cpp
+2
-2
tests/test_smart_ptr.cpp
tests/test_smart_ptr.cpp
+2
-2
tests/test_stl_binders.cpp
tests/test_stl_binders.cpp
+2
-2
tests/test_virtual_functions.cpp
tests/test_virtual_functions.cpp
+2
-2
No files found.
tests/test_pickling.cpp
View file @
2ea4b8e8
...
...
@@ -24,7 +24,7 @@ private:
int
m_extra2
=
0
;
};
void
init_ex_
pickling
(
py
::
module
&
m
)
{
test_initializer
pickling
(
[](
py
::
module
&
m
)
{
py
::
class_
<
Pickleable
>
(
m
,
"Pickleable"
)
.
def
(
py
::
init
<
std
::
string
>
())
.
def
(
"value"
,
&
Pickleable
::
value
)
...
...
@@ -48,4 +48,4 @@ void init_ex_pickling(py::module &m) {
p
.
setExtra1
(
t
[
1
].
cast
<
int
>
());
p
.
setExtra2
(
t
[
2
].
cast
<
int
>
());
});
}
}
);
tests/test_python_types.cpp
View file @
2ea4b8e8
...
...
@@ -167,7 +167,7 @@ public:
int
ExamplePythonTypes
::
value
=
0
;
const
int
ExamplePythonTypes
::
value2
=
5
;
void
init_ex_
python_types
(
py
::
module
&
m
)
{
test_initializer
python_types
(
[](
py
::
module
&
m
)
{
/* No constructor is explicitly defined below. An exception is raised when
trying to construct it directly from Python */
py
::
class_
<
ExamplePythonTypes
>
(
m
,
"ExamplePythonTypes"
,
"Example 2 documentation"
)
...
...
@@ -197,4 +197,4 @@ void init_ex_python_types(py::module &m) {
.
def_readwrite_static
(
"value"
,
&
ExamplePythonTypes
::
value
,
"Static value member"
)
.
def_readonly_static
(
"value2"
,
&
ExamplePythonTypes
::
value2
,
"Static value member (readonly)"
)
;
}
}
);
tests/test_sequences_and_iterators.cpp
View file @
2ea4b8e8
...
...
@@ -168,7 +168,7 @@ bool operator==(const NonZeroIterator<std::pair<A, B>>& it, const NonZeroSentine
return
!
(
*
it
).
first
||
!
(
*
it
).
second
;
}
void
init_ex_
sequences_and_iterators
(
py
::
module
&
m
)
{
test_initializer
sequences_and_iterators
(
[](
py
::
module
&
m
)
{
py
::
class_
<
Sequence
>
seq
(
m
,
"Sequence"
);
...
...
@@ -271,4 +271,4 @@ void init_ex_sequences_and_iterators(py::module &m) {
On the actual Sequence object, the iterator would be constructed as follows:
.def("__iter__", [](py::object s) { return PySequenceIterator(s.cast<const Sequence &>(), s); })
#endif
}
}
);
tests/test_smart_ptr.cpp
View file @
2ea4b8e8
...
...
@@ -105,7 +105,7 @@ void print_myobject3_2(std::shared_ptr<MyObject3> obj) { std::cout << obj->toStr
void
print_myobject3_3
(
const
std
::
shared_ptr
<
MyObject3
>
&
obj
)
{
std
::
cout
<<
obj
->
toString
()
<<
std
::
endl
;
}
void
print_myobject3_4
(
const
std
::
shared_ptr
<
MyObject3
>
*
obj
)
{
std
::
cout
<<
(
*
obj
)
->
toString
()
<<
std
::
endl
;
}
void
init_ex_
smart_ptr
(
py
::
module
&
m
)
{
test_initializer
smart_ptr
(
[](
py
::
module
&
m
)
{
py
::
class_
<
Object
,
ref
<
Object
>>
obj
(
m
,
"Object"
);
obj
.
def
(
"getRefCount"
,
&
Object
::
getRefCount
);
...
...
@@ -147,4 +147,4 @@ void init_ex_smart_ptr(py::module &m) {
// Expose constructor stats for the ref type
m
.
def
(
"cstats_ref"
,
&
ConstructorStats
::
get
<
ref_tag
>
);
}
}
);
tests/test_stl_binders.cpp
View file @
2ea4b8e8
...
...
@@ -24,7 +24,7 @@ std::ostream & operator<<(std::ostream &s, El const&v) {
return
s
;
}
void
init_ex_
stl_binder_vector
(
py
::
module
&
m
)
{
test_initializer
stl_binder_vector
(
[](
py
::
module
&
m
)
{
py
::
class_
<
El
>
(
m
,
"El"
)
.
def
(
py
::
init
<
int
>
());
...
...
@@ -34,4 +34,4 @@ void init_ex_stl_binder_vector(py::module &m) {
py
::
bind_vector
<
El
>
(
m
,
"VectorEl"
);
py
::
bind_vector
<
std
::
vector
<
El
>>
(
m
,
"VectorVectorEl"
);
}
}
);
tests/test_virtual_functions.cpp
View file @
2ea4b8e8
...
...
@@ -283,7 +283,7 @@ void initialize_inherited_virtuals(py::module &m) {
};
void
init_ex_
virtual_functions
(
py
::
module
&
m
)
{
test_initializer
virtual_functions
(
[](
py
::
module
&
m
)
{
/* Important: indicate the trampoline class PyExampleVirt using the third
argument to py::class_. The second argument with the unique pointer
is simply the default holder type used by pybind11. */
...
...
@@ -315,4 +315,4 @@ void init_ex_virtual_functions(py::module &m) {
m
.
def
(
"cstats_debug"
,
&
ConstructorStats
::
get
<
ExampleVirt
>
);
initialize_inherited_virtuals
(
m
);
}
}
);
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