添加属性管理功能单元测试

This commit is contained in:
2026-01-03 02:40:38 +08:00
parent e16b4f0a7f
commit 01815dfde5
2 changed files with 11 additions and 2 deletions

View File

@@ -51,7 +51,7 @@ TEST(test_flag_enum, basic_operations) {
// 检查标志计数 // 检查标志计数
auto count = count_flags(flags); auto count = count_flags(flags);
EXPECT_EQ(count, 2); EXPECT_EQ(count, 1);
// 检查设置和清除标志 // 检查设置和清除标志
set_flag(flags, my_enum1::cherry); set_flag(flags, my_enum1::cherry);
@@ -78,5 +78,13 @@ TEST(test_flag_enum, basic_operations) {
// 检查底层值转换 // 检查底层值转换
auto underlying = to_underlying(my_enum1::apple | my_enum1::banana); auto underlying = to_underlying(my_enum1::apple | my_enum1::banana);
EXPECT_EQ(underlying, 3); EXPECT_EQ(underlying, 1);
}
TEST(test_property, basic_operations) {
auto test_obj = mirai::make_obj<test_class1>();
test_obj->set_a(10);
auto a = test_obj->get_a();
EXPECT_EQ(a, 10);
} }

View File

@@ -4,6 +4,7 @@
class test_class1 : public mirai::object { class test_class1 : public mirai::object {
MIRAI_OBJECT_TYPE_INFO(test_class1, mirai::object) MIRAI_OBJECT_TYPE_INFO(test_class1, mirai::object)
PROPERTY(float, a, "", property_flags::none, 0.0f)
}; };
class test_class2 : public test_class1 { class test_class2 : public test_class1 {