|
|
|
|
@ -23,6 +23,7 @@
|
|
|
|
|
DEALINGS IN THE SOFTWARE. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <memory> |
|
|
|
|
#include <sstream> |
|
|
|
|
#include <Corrade/TestSuite/Tester.h> |
|
|
|
|
|
|
|
|
|
@ -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<int>&&): AbstractFeature3D{object} {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Object3D o; |
|
|
|
|
CORRADE_VERIFY(o.features().isEmpty()); |
|
|
|
|
MyFeature& f = o.addFeature<MyFeature>(0, "hello"); |
|
|
|
|
/* Test perfect forwarding as well */ |
|
|
|
|
int a = 0; |
|
|
|
|
MyFeature& f = o.addFeature<MyFeature>(a, std::unique_ptr<int>{}); |
|
|
|
|
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<int>&&, Object3D* parent = nullptr): Object3D{parent} {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Object3D o; |
|
|
|
|
CORRADE_VERIFY(o.children().isEmpty()); |
|
|
|
|
MyObject& p = o.addChild<MyObject>(0, "hello"); |
|
|
|
|
/* Test perfect forwarding as well */ |
|
|
|
|
int a = 0; |
|
|
|
|
MyObject& p = o.addChild<MyObject>(a, std::unique_ptr<int>{}); |
|
|
|
|
CORRADE_VERIFY(!o.children().isEmpty()); |
|
|
|
|
CORRADE_COMPARE(p.parent(), &o); |
|
|
|
|
} |
|
|
|
|
|