#include #include #include #include using namespace drogon; class TestA : public DrObject { }; namespace test { class TestB : public DrObject { }; } // namespace test TEST(DrObjectTest, creationTest) { using PtrType = std::shared_ptr; auto obj = PtrType(DrClassMap::newObject("TestA")); EXPECT_NE(obj, nullptr); auto objPtr = DrClassMap::getSingleInstance("TestA"); EXPECT_NE(objPtr.get(), nullptr); auto objPtr2 = DrClassMap::getSingleInstance(); EXPECT_NE(objPtr2.get(), nullptr); EXPECT_EQ(objPtr, objPtr2); } TEST(DrObjectTest, namespaceTest) { using PtrType = std::shared_ptr; auto obj = PtrType(DrClassMap::newObject("test::TestB")); EXPECT_NE(obj, nullptr); auto objPtr = DrClassMap::getSingleInstance("test::TestB"); EXPECT_NE(objPtr.get(), nullptr); auto objPtr2 = DrClassMap::getSingleInstance(); EXPECT_NE(objPtr2.get(), nullptr); EXPECT_EQ(objPtr, objPtr2); } int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }