2023-05-26 13:52:09 +01:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "oi/type_graph/TypeIdentifier.h"
|
2023-05-31 14:49:47 +01:00
|
|
|
#include "oi/type_graph/Types.h"
|
|
|
|
#include "test/type_graph_utils.h"
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
using namespace type_graph;
|
|
|
|
|
2023-05-31 14:49:47 +01:00
|
|
|
TEST(TypeIdentifierTest, StubbedParam) {
|
2023-11-13 16:50:09 +00:00
|
|
|
test(TypeIdentifier::createPass({}),
|
|
|
|
R"(
|
2023-05-31 14:49:47 +01:00
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
|
|
|
[1] Struct: MyParam (size: 4)
|
|
|
|
Member: a (offset: 0)
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
)",
|
|
|
|
R"(
|
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
2023-08-24 13:42:12 +01:00
|
|
|
[2] Dummy [MyParam] (size: 4)
|
2023-05-31 14:49:47 +01:00
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TypeIdentifierTest, Allocator) {
|
2023-11-13 16:50:09 +00:00
|
|
|
test(TypeIdentifier::createPass({}),
|
|
|
|
R"(
|
2023-05-31 14:49:47 +01:00
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
|
|
|
[1] Struct: MyAlloc (size: 8)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Function: allocate
|
|
|
|
Function: deallocate
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
)",
|
|
|
|
R"(
|
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
2023-08-24 13:42:12 +01:00
|
|
|
[2] DummyAllocator [MyAlloc] (size: 8)
|
2023-05-31 14:49:47 +01:00
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
2023-06-26 16:07:12 +01:00
|
|
|
TEST(TypeIdentifierTest, AllocatorSize1) {
|
2023-11-13 16:50:09 +00:00
|
|
|
test(TypeIdentifier::createPass({}),
|
|
|
|
R"(
|
2023-05-31 14:49:47 +01:00
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
2023-06-26 16:07:12 +01:00
|
|
|
[1] Struct: MyAlloc (size: 1)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
2023-05-31 14:49:47 +01:00
|
|
|
Function: allocate
|
|
|
|
Function: deallocate
|
2023-06-26 16:07:12 +01:00
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
2023-05-31 14:49:47 +01:00
|
|
|
)",
|
|
|
|
R"(
|
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
2023-08-24 13:42:12 +01:00
|
|
|
[2] DummyAllocator [MyAlloc] (size: 0)
|
2023-05-31 14:49:47 +01:00
|
|
|
Primitive: int32_t
|
2023-06-26 16:07:12 +01:00
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
2023-05-31 14:49:47 +01:00
|
|
|
)");
|
|
|
|
}
|
2023-07-06 14:10:04 +01:00
|
|
|
|
|
|
|
TEST(TypeIdentifierTest, PassThroughTypes) {
|
|
|
|
std::vector<ContainerInfo> passThroughTypes;
|
|
|
|
passThroughTypes.emplace_back("std::allocator", DUMMY_TYPE, "memory");
|
|
|
|
|
2023-11-13 16:50:09 +00:00
|
|
|
test(TypeIdentifier::createPass(passThroughTypes),
|
|
|
|
R"(
|
2023-07-06 14:10:04 +01:00
|
|
|
[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
|
2023-08-02 11:11:52 +01:00
|
|
|
[2] Container: std::allocator (size: 1)
|
2023-07-06 14:10:04 +01:00
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
2023-12-14 16:15:43 +00:00
|
|
|
Underlying
|
|
|
|
[1] Class: std::allocator (size: 1)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Function: allocate
|
|
|
|
Function: deallocate
|
2023-07-06 14:10:04 +01:00
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
2023-08-24 13:42:12 +01:00
|
|
|
TEST(TypeIdentifierTest, PassThroughSameType) {
|
|
|
|
std::vector<ContainerInfo> passThroughTypes;
|
|
|
|
passThroughTypes.emplace_back("std::allocator", DUMMY_TYPE, "memory");
|
|
|
|
|
2023-11-13 16:50:09 +00:00
|
|
|
test(TypeIdentifier::createPass(passThroughTypes),
|
|
|
|
R"(
|
2023-08-24 13:42:12 +01:00
|
|
|
[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
|
|
|
|
Param
|
|
|
|
[1]
|
|
|
|
)",
|
|
|
|
R"(
|
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
|
|
|
[2] Container: std::allocator (size: 1)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
2023-12-14 16:15:43 +00:00
|
|
|
Underlying
|
|
|
|
[1] Class: std::allocator (size: 1)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Function: allocate
|
|
|
|
Function: deallocate
|
2023-08-24 13:42:12 +01:00
|
|
|
Param
|
|
|
|
[2]
|
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
2023-07-06 14:10:04 +01:00
|
|
|
TEST(TypeIdentifierTest, ContainerNotReplaced) {
|
2023-11-13 16:50:09 +00:00
|
|
|
test(TypeIdentifier::createPass({}),
|
|
|
|
R"(
|
2023-07-06 14:10:04 +01:00
|
|
|
[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
|
2023-07-06 14:10:57 +01:00
|
|
|
[1] Container: std::allocator (size: 1)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
2023-07-06 14:10:04 +01:00
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TypeIdentifierTest, DummyNotReplaced) {
|
2023-08-01 19:06:02 +01:00
|
|
|
testNoChange(TypeIdentifier::createPass({}), R"(
|
2023-07-06 14:10:04 +01:00
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
2023-08-24 13:42:12 +01:00
|
|
|
[1] Dummy [InputName] (size: 22)
|
2023-07-06 14:10:04 +01:00
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TypeIdentifierTest, DummyAllocatorNotReplaced) {
|
2023-08-01 19:06:02 +01:00
|
|
|
testNoChange(TypeIdentifier::createPass({}), R"(
|
2023-07-06 14:10:04 +01:00
|
|
|
[0] Container: std::vector (size: 24)
|
|
|
|
Param
|
|
|
|
Primitive: int32_t
|
|
|
|
Param
|
2023-08-24 13:42:12 +01:00
|
|
|
[1] DummyAllocator [InputName] (size: 22)
|
2023-07-06 14:10:04 +01:00
|
|
|
Primitive: int32_t
|
|
|
|
)");
|
|
|
|
}
|