-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSmartPointerTest.cpp
More file actions
55 lines (43 loc) · 1.49 KB
/
SmartPointerTest.cpp
File metadata and controls
55 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <memory>
#include "KAI/Core/Object/Accessor.h"
#include "KAI/Core/Object/ClassBuilder.h"
#include "KAI/Core/Object/Method.h"
#include "KAI/Core/Type/Number.h"
#include "KAI/Core/Type/Traits.h"
using namespace kai;
// Test class
class TestClass {
public:
int value;
TestClass() : value(42) {}
void SetValue(int v) { value = v; }
int GetValue() const { return value; }
};
// Register TestClass with KAI's type system - using an arbitrary unused number
KAI_TYPE_TRAITS(TestClass, 200, Type::Properties::None);
int main() {
std::cout << "Testing smart pointer migration...\n";
// Test MakeMethod returning unique_ptr
{
auto method = MakeMethod(&TestClass::SetValue, Label("SetValue"));
std::cout << "✓ MakeMethod returns unique_ptr<MethodBase>\n";
}
// Test MakeProperty returning unique_ptr
{
auto prop = MakeProperty<TestClass>(&TestClass::value, Label("value"));
std::cout << "✓ MakeProperty returns unique_ptr<PropertyBase>\n";
}
// Test deprecated functions still work
{
auto method = MakeMethodRaw(&TestClass::GetValue, Label("GetValue"));
delete method;
std::cout << "✓ MakeMethodRaw (deprecated) still works\n";
auto prop =
MakePropertyRaw<TestClass>(&TestClass::value, Label("value"));
delete prop;
std::cout << "✓ MakePropertyRaw (deprecated) still works\n";
}
std::cout << "\nAll tests passed!\n";
return 0;
}