From d2a87d5803c7aaa9a47791a5a0f1494c19671ebc Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 26 Apr 2022 20:16:22 +0200 Subject: add project & make some tweaks Added from https://git.hampusmat.com/game-of-life --- test/container.test.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/container.test.cpp (limited to 'test/container.test.cpp') diff --git a/test/container.test.cpp b/test/container.test.cpp new file mode 100644 index 0000000..54290ea --- /dev/null +++ b/test/container.test.cpp @@ -0,0 +1,41 @@ +#include "yacppdic/container.hpp" +#include "yacppdic/auto_wirable.hpp" +#include "gtest/gtest.h" + +#include + +TEST(ContainerTest, BindAndGet) +{ + auto container = yacppdic::Container(); + + class IObject + { + public: + virtual ~IObject() = default; + + virtual void destroy() = 0; + + virtual std::string_view name() = 0; + }; + + class Object : public IObject, public yacppdic::AutoWirable + { + public: + void destroy() {} + + std::string_view name() + { + return "A object"; + } + }; + + container.bind().to(); + + auto object = container.get(); + + EXPECT_EQ(object->name(), "A object"); + + auto object_two = container.get(); + + EXPECT_NE(object, object_two); +} -- cgit v1.2.3-18-g5258