Files
mirai/tests/main.cpp

26 lines
797 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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");
}