Skip to content

Commit

Permalink
Added type caster test for std::vector<bool>
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliank committed Aug 9, 2023
1 parent 6a2ae30 commit 2169a3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,10 @@ NB_MODULE(test_stl_ext, m) {
nb::class_<ClassWithMovableField>(m, "ClassWithMovableField")
.def(nb::init<>())
.def_rw("movable", &ClassWithMovableField::movable);

// test67 std::vector<bool>
m.def("flip_vector_bool", [](std::vector<bool> vec) {
vec.flip();
return vec;
});
}
4 changes: 4 additions & 0 deletions tests/test_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,7 @@ def __fspath__(self):
assert t.parent_path(PseudoStrPath()) == Path("foo")
assert t.parent_path(PseudoBytesPath()) == Path("foo")

def test66_vector_bool():
bool_vector = [True, False, True, False]
result = t.flip_vector_bool(bool_vector)
assert result == [not x for x in bool_vector]

0 comments on commit 2169a3f

Please sign in to comment.