object-introspection/test/test_enforce_compatibility.cpp
Alastair Robertson 6fbb60826f
EnforceCompatibility: Stub out void pointers
CodeGen v1 does not record anything for pointers to incomplete types.
Not even the address, as is done for other pointers.

Introduce a new Primitive type "Incomplete". This behaves identically to
"Void", but allows us to tell whether a type was defined as void or if
it ended up like that because of incomplete DWARF information.
2023-07-31 14:28:05 +01:00

45 lines
987 B
C++

#include <gtest/gtest.h>
#include "oi/type_graph/EnforceCompatibility.h"
#include "test/type_graph_utils.h"
using namespace type_graph;
TEST(EnforceCompatibilityTest, ParentContainers) {
test(EnforceCompatibility::createPass(), R"(
[0] Class: MyClass (size: 24)
Member: __oi_parent (offset: 0)
[1] Container: std::vector (size: 24)
Param
Primitive: int32_t
)",
R"(
[0] Class: MyClass (size: 24)
)");
}
TEST(EnforceCompatibilityTest, TypesToStub) {
test(EnforceCompatibility::createPass(), R"(
[0] Class: EnumMap (size: 8)
Member: a (offset: 0)
Primitive: int32_t
Member: b (offset: 4)
Primitive: int32_t
)",
R"(
[0] Class: EnumMap (size: 8)
)");
}
TEST(EnforceCompatibilityTest, VoidPointer) {
test(EnforceCompatibility::createPass(), R"(
[0] Class: MyClass (size: 8)
Member: p (offset: 0)
[1] Pointer
Primitive: void (incomplete)
)",
R"(
[0] Class: MyClass (size: 8)
)");
}