mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-12 21:56:54 +00:00
TypeIdentifier: Add unit tests for preserving types
This commit is contained in:
parent
3ec81aaa5f
commit
9c45e0f22a
@ -114,3 +114,121 @@ TEST(TypeIdentifierTest, AllocatorSize1) {
|
||||
Primitive: int32_t
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(TypeIdentifierTest, PassThroughTypes) {
|
||||
auto myint = Primitive{Primitive::Kind::Int32};
|
||||
|
||||
auto myalloc = Class{1, Class::Kind::Class, "std::allocator", 1};
|
||||
myalloc.templateParams.push_back(TemplateParam{myint});
|
||||
myalloc.functions.push_back(Function{"allocate"});
|
||||
myalloc.functions.push_back(Function{"deallocate"});
|
||||
|
||||
auto container = getVector();
|
||||
container.templateParams.push_back(TemplateParam{myint});
|
||||
container.templateParams.push_back(TemplateParam{myalloc});
|
||||
|
||||
std::vector<ContainerInfo> passThroughTypes;
|
||||
passThroughTypes.emplace_back("std::allocator", DUMMY_TYPE, "memory");
|
||||
|
||||
test(TypeIdentifier::createPass(passThroughTypes), {container}, R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
[1] Class: std::allocator (size: 1)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Function: allocate
|
||||
Function: deallocate
|
||||
)",
|
||||
R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
[1] Container: std::allocator (size: 1)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(TypeIdentifierTest, ContainerNotReplaced) {
|
||||
auto myint = Primitive{Primitive::Kind::Int32};
|
||||
|
||||
ContainerInfo allocatorInfo{"std::allocator", DUMMY_TYPE, "memory"};
|
||||
auto myalloc = Container{1, allocatorInfo, 1};
|
||||
myalloc.templateParams.push_back(TemplateParam{myint});
|
||||
|
||||
auto container = getVector();
|
||||
container.templateParams.push_back(TemplateParam{myint});
|
||||
container.templateParams.push_back(TemplateParam{myalloc});
|
||||
|
||||
test(TypeIdentifier::createPass({}), {container}, R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
[1] Container: std::allocator (size: 1)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
)",
|
||||
R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
Dummy (size: 0, align: 8)
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(TypeIdentifierTest, DummyNotReplaced) {
|
||||
auto myint = Primitive{Primitive::Kind::Int32};
|
||||
|
||||
auto dummy = Dummy{22, 0};
|
||||
|
||||
auto container = getVector();
|
||||
container.templateParams.push_back(TemplateParam{myint});
|
||||
container.templateParams.push_back(TemplateParam{dummy});
|
||||
|
||||
test(TypeIdentifier::createPass({}), {container}, R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
Dummy (size: 22)
|
||||
)",
|
||||
R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
Dummy (size: 22)
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(TypeIdentifierTest, DummyAllocatorNotReplaced) {
|
||||
auto myint = Primitive{Primitive::Kind::Int32};
|
||||
|
||||
auto dummy = DummyAllocator{myint, 22, 0};
|
||||
|
||||
auto container = getVector();
|
||||
container.templateParams.push_back(TemplateParam{myint});
|
||||
container.templateParams.push_back(TemplateParam{dummy});
|
||||
|
||||
test(TypeIdentifier::createPass({}), {container}, R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
DummyAllocator (size: 22)
|
||||
Primitive: int32_t
|
||||
)",
|
||||
R"(
|
||||
[0] Container: std::vector (size: 24)
|
||||
Param
|
||||
Primitive: int32_t
|
||||
Param
|
||||
DummyAllocator (size: 22)
|
||||
Primitive: int32_t
|
||||
)");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user