2017-05-14 19:57:26 +00:00
|
|
|
/*
|
|
|
|
tests/test_copy_move_policies.cpp -- 'copy' and 'move' return value policies
|
|
|
|
and related tests
|
|
|
|
|
|
|
|
Copyright (c) 2016 Ben North <ben@redfrontdoor.org>
|
|
|
|
|
|
|
|
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 "constructor_stats.h"
|
|
|
|
#include <pybind11/stl.h>
|
|
|
|
|
|
|
|
template <typename derived>
|
|
|
|
struct empty {
|
|
|
|
static const derived& get_one() { return instance_; }
|
|
|
|
static derived instance_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lacking_copy_ctor : public empty<lacking_copy_ctor> {
|
2020-09-11 03:15:22 +00:00
|
|
|
lacking_copy_ctor() = default;
|
2017-05-14 19:57:26 +00:00
|
|
|
lacking_copy_ctor(const lacking_copy_ctor& other) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> lacking_copy_ctor empty<lacking_copy_ctor>::instance_ = {};
|
|
|
|
|
|
|
|
struct lacking_move_ctor : public empty<lacking_move_ctor> {
|
2020-09-11 03:15:22 +00:00
|
|
|
lacking_move_ctor() = default;
|
2017-05-14 19:57:26 +00:00
|
|
|
lacking_move_ctor(const lacking_move_ctor& other) = delete;
|
|
|
|
lacking_move_ctor(lacking_move_ctor&& other) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> lacking_move_ctor empty<lacking_move_ctor>::instance_ = {};
|
|
|
|
|
|
|
|
/* Custom type caster move/copy test classes */
|
|
|
|
class MoveOnlyInt {
|
|
|
|
public:
|
|
|
|
MoveOnlyInt() { print_default_created(this); }
|
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy
* clang-tidy explicit attr.h (all automatic)
* clang-tidy explicit cast.h (all automatic)
* clang-tidy detail/init.h (1 NOLINT)
* clang-tidy detail/type_caster_base.h (2 NOLINT)
* clang-tidy pybind11.h (7 NOLINT)
* clang-tidy detail/common.h (3 NOLINT)
* clang-tidy detail/descr.h (2 NOLINT)
* clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
* clang-tidy eigen.h (7 NOLINT, 0 explicit)
* Adding 2 explicit in functional.h
* Adding 4 explicit in iostream.h
* clang-tidy numpy.h (1 NOLINT, 1 explicit)
* clang-tidy embed.h (0 NOLINT, 1 explicit)
* clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
* clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
* clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
* clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
* clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
* clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
* clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/object.h (0 NOLINT, 2 explicit)
* clang-tidy batch of fully automatic fixes.
* Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
2021-09-09 01:53:38 +00:00
|
|
|
explicit MoveOnlyInt(int v) : value{v} { print_created(this, value); }
|
2021-06-22 16:11:54 +00:00
|
|
|
MoveOnlyInt(MoveOnlyInt &&m) noexcept {
|
|
|
|
print_move_created(this, m.value);
|
|
|
|
std::swap(value, m.value);
|
|
|
|
}
|
|
|
|
MoveOnlyInt &operator=(MoveOnlyInt &&m) noexcept {
|
|
|
|
print_move_assigned(this, m.value);
|
|
|
|
std::swap(value, m.value);
|
|
|
|
return *this;
|
|
|
|
}
|
2017-05-14 19:57:26 +00:00
|
|
|
MoveOnlyInt(const MoveOnlyInt &) = delete;
|
|
|
|
MoveOnlyInt &operator=(const MoveOnlyInt &) = delete;
|
|
|
|
~MoveOnlyInt() { print_destroyed(this); }
|
|
|
|
|
|
|
|
int value;
|
|
|
|
};
|
|
|
|
class MoveOrCopyInt {
|
|
|
|
public:
|
|
|
|
MoveOrCopyInt() { print_default_created(this); }
|
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy
* clang-tidy explicit attr.h (all automatic)
* clang-tidy explicit cast.h (all automatic)
* clang-tidy detail/init.h (1 NOLINT)
* clang-tidy detail/type_caster_base.h (2 NOLINT)
* clang-tidy pybind11.h (7 NOLINT)
* clang-tidy detail/common.h (3 NOLINT)
* clang-tidy detail/descr.h (2 NOLINT)
* clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
* clang-tidy eigen.h (7 NOLINT, 0 explicit)
* Adding 2 explicit in functional.h
* Adding 4 explicit in iostream.h
* clang-tidy numpy.h (1 NOLINT, 1 explicit)
* clang-tidy embed.h (0 NOLINT, 1 explicit)
* clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
* clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
* clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
* clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
* clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
* clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
* clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/object.h (0 NOLINT, 2 explicit)
* clang-tidy batch of fully automatic fixes.
* Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
2021-09-09 01:53:38 +00:00
|
|
|
explicit MoveOrCopyInt(int v) : value{v} { print_created(this, value); }
|
2021-06-22 16:11:54 +00:00
|
|
|
MoveOrCopyInt(MoveOrCopyInt &&m) noexcept {
|
|
|
|
print_move_created(this, m.value);
|
|
|
|
std::swap(value, m.value);
|
|
|
|
}
|
|
|
|
MoveOrCopyInt &operator=(MoveOrCopyInt &&m) noexcept {
|
|
|
|
print_move_assigned(this, m.value);
|
|
|
|
std::swap(value, m.value);
|
|
|
|
return *this;
|
|
|
|
}
|
2017-05-14 19:57:26 +00:00
|
|
|
MoveOrCopyInt(const MoveOrCopyInt &c) { print_copy_created(this, c.value); value = c.value; }
|
|
|
|
MoveOrCopyInt &operator=(const MoveOrCopyInt &c) { print_copy_assigned(this, c.value); value = c.value; return *this; }
|
|
|
|
~MoveOrCopyInt() { print_destroyed(this); }
|
|
|
|
|
|
|
|
int value;
|
|
|
|
};
|
|
|
|
class CopyOnlyInt {
|
|
|
|
public:
|
|
|
|
CopyOnlyInt() { print_default_created(this); }
|
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy
* clang-tidy explicit attr.h (all automatic)
* clang-tidy explicit cast.h (all automatic)
* clang-tidy detail/init.h (1 NOLINT)
* clang-tidy detail/type_caster_base.h (2 NOLINT)
* clang-tidy pybind11.h (7 NOLINT)
* clang-tidy detail/common.h (3 NOLINT)
* clang-tidy detail/descr.h (2 NOLINT)
* clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
* clang-tidy eigen.h (7 NOLINT, 0 explicit)
* Adding 2 explicit in functional.h
* Adding 4 explicit in iostream.h
* clang-tidy numpy.h (1 NOLINT, 1 explicit)
* clang-tidy embed.h (0 NOLINT, 1 explicit)
* clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
* clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
* clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
* clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
* clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
* clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
* clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/object.h (0 NOLINT, 2 explicit)
* clang-tidy batch of fully automatic fixes.
* Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
2021-09-09 01:53:38 +00:00
|
|
|
explicit CopyOnlyInt(int v) : value{v} { print_created(this, value); }
|
2017-05-14 19:57:26 +00:00
|
|
|
CopyOnlyInt(const CopyOnlyInt &c) { print_copy_created(this, c.value); value = c.value; }
|
|
|
|
CopyOnlyInt &operator=(const CopyOnlyInt &c) { print_copy_assigned(this, c.value); value = c.value; return *this; }
|
|
|
|
~CopyOnlyInt() { print_destroyed(this); }
|
|
|
|
|
|
|
|
int value;
|
|
|
|
};
|
2020-07-08 22:14:41 +00:00
|
|
|
PYBIND11_NAMESPACE_BEGIN(pybind11)
|
|
|
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
2017-05-14 19:57:26 +00:00
|
|
|
template <> struct type_caster<MoveOnlyInt> {
|
|
|
|
PYBIND11_TYPE_CASTER(MoveOnlyInt, _("MoveOnlyInt"));
|
|
|
|
bool load(handle src, bool) { value = MoveOnlyInt(src.cast<int>()); return true; }
|
|
|
|
static handle cast(const MoveOnlyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct type_caster<MoveOrCopyInt> {
|
|
|
|
PYBIND11_TYPE_CASTER(MoveOrCopyInt, _("MoveOrCopyInt"));
|
|
|
|
bool load(handle src, bool) { value = MoveOrCopyInt(src.cast<int>()); return true; }
|
|
|
|
static handle cast(const MoveOrCopyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct type_caster<CopyOnlyInt> {
|
|
|
|
protected:
|
|
|
|
CopyOnlyInt value;
|
|
|
|
public:
|
2017-07-02 09:48:56 +00:00
|
|
|
static constexpr auto name = _("CopyOnlyInt");
|
2017-05-14 19:57:26 +00:00
|
|
|
bool load(handle src, bool) { value = CopyOnlyInt(src.cast<int>()); return true; }
|
|
|
|
static handle cast(const CopyOnlyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); }
|
|
|
|
static handle cast(const CopyOnlyInt *src, return_value_policy policy, handle parent) {
|
|
|
|
if (!src) return none().release();
|
|
|
|
return cast(*src, policy, parent);
|
|
|
|
}
|
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy
* clang-tidy explicit attr.h (all automatic)
* clang-tidy explicit cast.h (all automatic)
* clang-tidy detail/init.h (1 NOLINT)
* clang-tidy detail/type_caster_base.h (2 NOLINT)
* clang-tidy pybind11.h (7 NOLINT)
* clang-tidy detail/common.h (3 NOLINT)
* clang-tidy detail/descr.h (2 NOLINT)
* clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
* clang-tidy eigen.h (7 NOLINT, 0 explicit)
* Adding 2 explicit in functional.h
* Adding 4 explicit in iostream.h
* clang-tidy numpy.h (1 NOLINT, 1 explicit)
* clang-tidy embed.h (0 NOLINT, 1 explicit)
* clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
* clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
* clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
* clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
* clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
* clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
* clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/object.h (0 NOLINT, 2 explicit)
* clang-tidy batch of fully automatic fixes.
* Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
2021-09-09 01:53:38 +00:00
|
|
|
explicit operator CopyOnlyInt *() { return &value; }
|
|
|
|
explicit operator CopyOnlyInt &() { return value; }
|
2017-05-14 19:57:26 +00:00
|
|
|
template <typename T> using cast_op_type = pybind11::detail::cast_op_type<T>;
|
|
|
|
};
|
2020-07-08 22:14:41 +00:00
|
|
|
PYBIND11_NAMESPACE_END(detail)
|
|
|
|
PYBIND11_NAMESPACE_END(pybind11)
|
2017-05-14 19:57:26 +00:00
|
|
|
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
TEST_SUBMODULE(copy_move_policies, m) {
|
|
|
|
// test_lacking_copy_ctor
|
2017-05-14 19:57:26 +00:00
|
|
|
py::class_<lacking_copy_ctor>(m, "lacking_copy_ctor")
|
|
|
|
.def_static("get_one", &lacking_copy_ctor::get_one,
|
|
|
|
py::return_value_policy::copy);
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
// test_lacking_move_ctor
|
2017-05-14 19:57:26 +00:00
|
|
|
py::class_<lacking_move_ctor>(m, "lacking_move_ctor")
|
|
|
|
.def_static("get_one", &lacking_move_ctor::get_one,
|
|
|
|
py::return_value_policy::move);
|
|
|
|
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
// test_move_and_copy_casts
|
2021-06-22 16:11:54 +00:00
|
|
|
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
2021-07-12 20:10:28 +00:00
|
|
|
m.def("move_and_copy_casts", [](const py::object &o) {
|
2017-05-14 19:57:26 +00:00
|
|
|
int r = 0;
|
|
|
|
r += py::cast<MoveOrCopyInt>(o).value; /* moves */
|
|
|
|
r += py::cast<MoveOnlyInt>(o).value; /* moves */
|
|
|
|
r += py::cast<CopyOnlyInt>(o).value; /* copies */
|
2020-11-09 18:10:19 +00:00
|
|
|
auto m1(py::cast<MoveOrCopyInt>(o)); /* moves */
|
|
|
|
auto m2(py::cast<MoveOnlyInt>(o)); /* moves */
|
|
|
|
auto m3(py::cast<CopyOnlyInt>(o)); /* copies */
|
2017-05-14 19:57:26 +00:00
|
|
|
r += m1.value + m2.value + m3.value;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
});
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
|
|
|
|
// test_move_and_copy_loads
|
|
|
|
m.def("move_only", [](MoveOnlyInt m) { return m.value; });
|
2021-07-12 20:10:28 +00:00
|
|
|
// Changing this breaks the existing test: needs careful review.
|
2021-06-22 16:11:54 +00:00
|
|
|
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
m.def("move_or_copy", [](MoveOrCopyInt m) { return m.value; });
|
2021-07-12 20:10:28 +00:00
|
|
|
// Changing this breaks the existing test: needs careful review.
|
2021-06-22 16:11:54 +00:00
|
|
|
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
m.def("copy_only", [](CopyOnlyInt m) { return m.value; });
|
2017-05-14 19:57:26 +00:00
|
|
|
m.def("move_pair", [](std::pair<MoveOnlyInt, MoveOrCopyInt> p) {
|
|
|
|
return p.first.value + p.second.value;
|
|
|
|
});
|
|
|
|
m.def("move_tuple", [](std::tuple<MoveOnlyInt, MoveOrCopyInt, MoveOnlyInt> t) {
|
|
|
|
return std::get<0>(t).value + std::get<1>(t).value + std::get<2>(t).value;
|
|
|
|
});
|
|
|
|
m.def("copy_tuple", [](std::tuple<CopyOnlyInt, CopyOnlyInt> t) {
|
|
|
|
return std::get<0>(t).value + std::get<1>(t).value;
|
|
|
|
});
|
|
|
|
m.def("move_copy_nested", [](std::pair<MoveOnlyInt, std::pair<std::tuple<MoveOrCopyInt, CopyOnlyInt, std::tuple<MoveOnlyInt>>, MoveOrCopyInt>> x) {
|
|
|
|
return x.first.value + std::get<0>(x.second.first).value + std::get<1>(x.second.first).value +
|
|
|
|
std::get<0>(std::get<2>(x.second.first)).value + x.second.second.value;
|
|
|
|
});
|
|
|
|
m.def("move_and_copy_cstats", []() {
|
|
|
|
ConstructorStats::gc();
|
|
|
|
// Reset counts to 0 so that previous tests don't affect later ones:
|
|
|
|
auto &mc = ConstructorStats::get<MoveOrCopyInt>();
|
|
|
|
mc.move_assignments = mc.move_constructions = mc.copy_assignments = mc.copy_constructions = 0;
|
|
|
|
auto &mo = ConstructorStats::get<MoveOnlyInt>();
|
|
|
|
mo.move_assignments = mo.move_constructions = mo.copy_assignments = mo.copy_constructions = 0;
|
|
|
|
auto &co = ConstructorStats::get<CopyOnlyInt>();
|
|
|
|
co.move_assignments = co.move_constructions = co.copy_assignments = co.copy_constructions = 0;
|
|
|
|
py::dict d;
|
|
|
|
d["MoveOrCopyInt"] = py::cast(mc, py::return_value_policy::reference);
|
|
|
|
d["MoveOnlyInt"] = py::cast(mo, py::return_value_policy::reference);
|
|
|
|
d["CopyOnlyInt"] = py::cast(co, py::return_value_policy::reference);
|
|
|
|
return d;
|
|
|
|
});
|
|
|
|
#ifdef PYBIND11_HAS_OPTIONAL
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
// test_move_and_copy_load_optional
|
2017-05-14 19:57:26 +00:00
|
|
|
m.attr("has_optional") = true;
|
|
|
|
m.def("move_optional", [](std::optional<MoveOnlyInt> o) {
|
|
|
|
return o->value;
|
|
|
|
});
|
|
|
|
m.def("move_or_copy_optional", [](std::optional<MoveOrCopyInt> o) {
|
|
|
|
return o->value;
|
|
|
|
});
|
|
|
|
m.def("copy_optional", [](std::optional<CopyOnlyInt> o) {
|
|
|
|
return o->value;
|
|
|
|
});
|
|
|
|
m.def("move_optional_tuple", [](std::optional<std::tuple<MoveOrCopyInt, MoveOnlyInt, CopyOnlyInt>> x) {
|
|
|
|
return std::get<0>(*x).value + std::get<1>(*x).value + std::get<2>(*x).value;
|
|
|
|
});
|
|
|
|
#else
|
|
|
|
m.attr("has_optional") = false;
|
|
|
|
#endif
|
|
|
|
|
2020-09-10 15:49:26 +00:00
|
|
|
// #70 compilation issue if operator new is not public - simple body added
|
|
|
|
// but not needed on most compilers; MSVC and nvcc don't like a local
|
|
|
|
// struct not having a method defined when declared, since it can not be
|
|
|
|
// added later.
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
struct PrivateOpNew {
|
|
|
|
int value = 1;
|
|
|
|
private:
|
2020-09-10 15:49:26 +00:00
|
|
|
void *operator new(size_t bytes) {
|
|
|
|
void *ptr = std::malloc(bytes);
|
|
|
|
if (ptr)
|
|
|
|
return ptr;
|
2021-07-09 13:45:53 +00:00
|
|
|
throw std::bad_alloc{};
|
2020-09-10 15:49:26 +00:00
|
|
|
}
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
};
|
2017-06-08 16:21:12 +00:00
|
|
|
py::class_<PrivateOpNew>(m, "PrivateOpNew").def_readonly("value", &PrivateOpNew::value);
|
|
|
|
m.def("private_op_new_value", []() { return PrivateOpNew(); });
|
|
|
|
m.def("private_op_new_reference", []() -> const PrivateOpNew & {
|
|
|
|
static PrivateOpNew x{};
|
|
|
|
return x;
|
|
|
|
}, py::return_value_policy::reference);
|
2017-06-07 14:52:50 +00:00
|
|
|
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
// test_move_fallback
|
2017-06-07 14:52:50 +00:00
|
|
|
// #389: rvp::move should fall-through to copy on non-movable objects
|
|
|
|
struct MoveIssue1 {
|
|
|
|
int v;
|
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy
* clang-tidy explicit attr.h (all automatic)
* clang-tidy explicit cast.h (all automatic)
* clang-tidy detail/init.h (1 NOLINT)
* clang-tidy detail/type_caster_base.h (2 NOLINT)
* clang-tidy pybind11.h (7 NOLINT)
* clang-tidy detail/common.h (3 NOLINT)
* clang-tidy detail/descr.h (2 NOLINT)
* clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
* clang-tidy eigen.h (7 NOLINT, 0 explicit)
* Adding 2 explicit in functional.h
* Adding 4 explicit in iostream.h
* clang-tidy numpy.h (1 NOLINT, 1 explicit)
* clang-tidy embed.h (0 NOLINT, 1 explicit)
* clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
* clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
* clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
* clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
* clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
* clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
* clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/object.h (0 NOLINT, 2 explicit)
* clang-tidy batch of fully automatic fixes.
* Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
2021-09-09 01:53:38 +00:00
|
|
|
explicit MoveIssue1(int v) : v{v} {}
|
2017-06-07 14:52:50 +00:00
|
|
|
MoveIssue1(const MoveIssue1 &c) = default;
|
|
|
|
MoveIssue1(MoveIssue1 &&) = delete;
|
|
|
|
};
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
py::class_<MoveIssue1>(m, "MoveIssue1").def(py::init<int>()).def_readwrite("value", &MoveIssue1::v);
|
2017-06-07 14:52:50 +00:00
|
|
|
|
|
|
|
struct MoveIssue2 {
|
|
|
|
int v;
|
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy
* clang-tidy explicit attr.h (all automatic)
* clang-tidy explicit cast.h (all automatic)
* clang-tidy detail/init.h (1 NOLINT)
* clang-tidy detail/type_caster_base.h (2 NOLINT)
* clang-tidy pybind11.h (7 NOLINT)
* clang-tidy detail/common.h (3 NOLINT)
* clang-tidy detail/descr.h (2 NOLINT)
* clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
* clang-tidy eigen.h (7 NOLINT, 0 explicit)
* Adding 2 explicit in functional.h
* Adding 4 explicit in iostream.h
* clang-tidy numpy.h (1 NOLINT, 1 explicit)
* clang-tidy embed.h (0 NOLINT, 1 explicit)
* clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
* clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
* clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
* clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
* clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
* clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
* clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
* clang-tidy tests/object.h (0 NOLINT, 2 explicit)
* clang-tidy batch of fully automatic fixes.
* Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
2021-09-09 01:53:38 +00:00
|
|
|
explicit MoveIssue2(int v) : v{v} {}
|
2017-06-07 14:52:50 +00:00
|
|
|
MoveIssue2(MoveIssue2 &&) = default;
|
|
|
|
};
|
|
|
|
py::class_<MoveIssue2>(m, "MoveIssue2").def(py::init<int>()).def_readwrite("value", &MoveIssue2::v);
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
|
2021-01-01 16:05:22 +00:00
|
|
|
// #2742: Don't expect ownership of raw pointer to `new`ed object to be transferred with `py::return_value_policy::move`
|
|
|
|
m.def("get_moveissue1", [](int i) { return std::unique_ptr<MoveIssue1>(new MoveIssue1(i)); }, py::return_value_policy::move);
|
2017-06-07 14:52:50 +00:00
|
|
|
m.def("get_moveissue2", [](int i) { return MoveIssue2(i); }, py::return_value_policy::move);
|
Update all remaining tests to new test styles
This udpates all the remaining tests to the new test suite code and
comment styles started in #898. For the most part, the test coverage
here is unchanged, with a few minor exceptions as noted below.
- test_constants_and_functions: this adds more overload tests with
overloads with different number of arguments for more comprehensive
overload_cast testing. The test style conversion broke the overload
tests under MSVC 2015, prompting the additional tests while looking
for a workaround.
- test_eigen: this dropped the unused functions `get_cm_corners` and
`get_cm_corners_const`--these same tests were duplicates of the same
things provided (and used) via ReturnTester methods.
- test_opaque_types: this test had a hidden dependence on ExampleMandA
which is now fixed by using the global UserType which suffices for the
relevant test.
- test_methods_and_attributes: this required some additions to UserType
to make it usable as a replacement for the test's previous SimpleType:
UserType gained a value mutator, and the `value` property is not
mutable (it was previously readonly). Some overload tests were also
added to better test overload_cast (as described above).
- test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
the templated versions with an empty parameter pack expand to the same
thing.
- test_stl: this was already mostly in the new style; this just tweaks
things a bit, localizing a class, and adding some missing
`// test_whatever` comments.
- test_virtual_functions: like `test_stl`, this was mostly in the new
test style already, but needed some `// test_whatever` comments.
This commit also moves the inherited virtual example code to the end
of the file, after the main set of tests (since it is less important
than the other tests, and rather length); it also got renamed to
`test_inherited_virtuals` (from `test_inheriting_repeat`) because it
tests both inherited virtual approaches, not just the repeat approach.
2017-07-25 20:47:36 +00:00
|
|
|
}
|