#include #include #include "Core/Object.h" #include "Core/Property.h" #include using namespace uLib; class TestObject : public Object { public: TestObject() : Object(), IntProp(this, "IntProp", 10), StringProp(this, "StringProp", "Initial") {} virtual const char* GetClassName() const override { return "TestObject"; } Property IntProp; Property StringProp; }; int main() { TestObject obj; std::cout << "Testing Properties..." << std::endl; // 1. Check registration const auto& props = obj.GetProperties(); assert(props.size() == 2); assert(props[0]->GetName() == "IntProp"); assert(props[1]->GetName() == "StringProp"); // 2. Check value access and signals bool signalCalled = false; uLib::Object::connect(&obj.IntProp, &Property::PropertyChanged, [&signalCalled]() { signalCalled = true; }); assert(obj.IntProp.Get() == 10); obj.IntProp = 20; assert(obj.IntProp.Get() == 20); assert(signalCalled == true); // 3. Check serialization std::stringstream ss; Object::SaveXml(ss, obj); std::string xml = ss.str(); std::cout << "Serialized XML: \n" << xml << std::endl; assert(xml.find("20") != std::string::npos); assert(xml.find("Initial") != std::string::npos); // 4. Check deserialization TestObject obj2; std::stringstream ss2(xml); Object::LoadXml(ss2, obj2); assert(obj2.IntProp.Get() == 20); assert(obj2.StringProp.Get() == "Initial"); std::cout << "All Property Tests PASSED!" << std::endl; return 0; }