mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
Port tests to pytest
Use simple asserts and pytest's powerful introspection to make testing simpler. This merges the old .py/.ref file pairs into simple .py files where the expected values are right next to the code being tested. This commit does not touch the C++ part of the code and replicates the Python tests exactly like the old .ref-file-based approach.
This commit is contained in:
37
tests/test_stl_binders.cpp
Normal file
37
tests/test_stl_binders.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
tests/test_stl_binders.cpp -- Usage of stl_binders functions
|
||||
|
||||
Copyright (c) 2016 Sergey Lyskov
|
||||
|
||||
All rights reserved. Use of this source code is governed by a
|
||||
BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "pybind11_tests.h"
|
||||
|
||||
#include <pybind11/stl_bind.h>
|
||||
|
||||
class El {
|
||||
public:
|
||||
El() = delete;
|
||||
El(int v) : a(v) { }
|
||||
|
||||
int a;
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream &s, El const&v) {
|
||||
s << "El{" << v.a << '}';
|
||||
return s;
|
||||
}
|
||||
|
||||
void init_ex_stl_binder_vector(py::module &m) {
|
||||
py::class_<El>(m, "El")
|
||||
.def(py::init<int>());
|
||||
|
||||
py::bind_vector<unsigned int>(m, "VectorInt");
|
||||
py::bind_vector<bool>(m, "VectorBool");
|
||||
|
||||
py::bind_vector<El>(m, "VectorEl");
|
||||
|
||||
py::bind_vector<std::vector<El>>(m, "VectorVectorEl");
|
||||
}
|
||||
Reference in New Issue
Block a user