mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
a0c1ccf0a9
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.
38 lines
755 B
C++
38 lines
755 B
C++
/*
|
|
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");
|
|
}
|