#include "coco/IR/FeatureObject.h"
+#include "nncc/foundation/Memory.h"
+
#include "Def.mock.h"
#include <gtest/gtest.h>
+using nncc::foundation::make_unique;
+
namespace
{
class DefSlotTest : public ::testing::Test
ASSERT_EQ(o->def(), nullptr);
}
+
+TEST_F(DefSlotTest, unlink_on_destruction)
+{
+ auto o = obj_mgr.create(nncc::core::ADT::feature::Shape{1, 1, 1});
+
+ ::mock::Def def;
+
+ auto slot = make_unique<coco::DefSlot<coco::FeatureObject>>(&obj_link, &def);
+
+ slot->value(o);
+ ASSERT_EQ(o->def(), &def);
+
+ // Let's destruct the allocated slot
+ slot.reset(nullptr);
+
+ // The def of Object SHOULD BE updated
+ ASSERT_EQ(o->def(), nullptr);
+}