26 lines
797 B
C++
26 lines
797 B
C++
#include <gtest/gtest.h>
|
||
#include "object_test.h"
|
||
|
||
TEST(test_object, derived) {
|
||
auto test_obj = mirai::make_obj<test_class1>();
|
||
auto test_obj2 = mirai::make_obj<test_class2>();
|
||
|
||
// 检查类型信息
|
||
|
||
// test_obj应该继承自mirai::object
|
||
EXPECT_TRUE(test_obj->is<mirai::object>());
|
||
EXPECT_TRUE(test_obj2->is<mirai::object>());
|
||
|
||
// test_obj应该是test_class1类型,但不是test_class2类型
|
||
EXPECT_TRUE(test_obj->is<test_class1>());
|
||
EXPECT_FALSE(test_obj->is<test_class2>());
|
||
|
||
// test_obj2应该是test_class2类型,也是test_class1类型
|
||
EXPECT_TRUE(test_obj2->is<test_class2>());
|
||
EXPECT_TRUE(test_obj2->is<test_class1>());
|
||
|
||
// test_obj的类型名称检查
|
||
EXPECT_EQ(test_obj->type_name(), "class test_class1");
|
||
EXPECT_EQ(test_obj2->type_name(), "class test_class2");
|
||
}
|