From c1206629a03673f03d15bc9e8391635bc4ffa5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 12 Oct 2018 17:16:17 +0200 Subject: [PATCH] SceneGraph: properly test perfect forwarding in addFeature()/addObject(). It's not working, obviously. --- src/Magnum/SceneGraph/Test/ObjectTest.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Magnum/SceneGraph/Test/ObjectTest.cpp b/src/Magnum/SceneGraph/Test/ObjectTest.cpp index 6090e7f07..457f2075b 100644 --- a/src/Magnum/SceneGraph/Test/ObjectTest.cpp +++ b/src/Magnum/SceneGraph/Test/ObjectTest.cpp @@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #include @@ -93,12 +94,14 @@ ObjectTest::ObjectTest() { void ObjectTest::addFeature() { class MyFeature: public AbstractFeature3D { public: - explicit MyFeature(AbstractObject3D& object, Int, std::string&&): AbstractFeature3D{object} {} + explicit MyFeature(AbstractObject3D& object, Int&, std::unique_ptr&&): AbstractFeature3D{object} {} }; Object3D o; CORRADE_VERIFY(o.features().isEmpty()); - MyFeature& f = o.addFeature(0, "hello"); + /* Test perfect forwarding as well */ + int a = 0; + MyFeature& f = o.addFeature(a, std::unique_ptr{}); CORRADE_VERIFY(!o.features().isEmpty()); CORRADE_COMPARE(&f.object(), &o); } @@ -136,12 +139,14 @@ void ObjectTest::parenting() { void ObjectTest::addChild() { class MyObject: public Object3D { public: - explicit MyObject(Int, std::string&&, Object3D* parent = nullptr): Object3D{parent} {} + explicit MyObject(Int&, std::unique_ptr&&, Object3D* parent = nullptr): Object3D{parent} {} }; Object3D o; CORRADE_VERIFY(o.children().isEmpty()); - MyObject& p = o.addChild(0, "hello"); + /* Test perfect forwarding as well */ + int a = 0; + MyObject& p = o.addChild(a, std::unique_ptr{}); CORRADE_VERIFY(!o.children().isEmpty()); CORRADE_COMPARE(p.parent(), &o); }