mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
e1b16a3d7e
References must always have a value, so are semantically clearer than pointers for variables which must always be set. No functional changes.
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "oi/type_graph/RemoveTopLevelPointer.h"
|
|
#include "oi/type_graph/Types.h"
|
|
#include "test/type_graph_utils.h"
|
|
|
|
using namespace type_graph;
|
|
|
|
TEST(RemoveTopLevelPointerTest, TopLevelPointerRemoved) {
|
|
auto myint = Primitive{Primitive::Kind::Int32};
|
|
|
|
auto myclass = Class{1, Class::Kind::Class, "MyClass", 4};
|
|
myclass.members.push_back(Member{myint, "n", 0});
|
|
|
|
auto ptrA = Pointer{0, myclass};
|
|
|
|
test(RemoveTopLevelPointer::createPass(), {ptrA}, R"(
|
|
[0] Class: MyClass (size: 4)
|
|
Member: n (offset: 0)
|
|
Primitive: int32_t
|
|
)");
|
|
}
|
|
|
|
TEST(RemoveTopLevelPointerTest, TopLevelClassUntouched) {
|
|
auto myint = Primitive{Primitive::Kind::Int32};
|
|
|
|
auto myclass = Class{0, Class::Kind::Class, "MyClass", 4};
|
|
myclass.members.push_back(Member{myint, "n", 0});
|
|
|
|
test(RemoveTopLevelPointer::createPass(), {myclass}, R"(
|
|
[0] Class: MyClass (size: 4)
|
|
Member: n (offset: 0)
|
|
Primitive: int32_t
|
|
)");
|
|
}
|
|
|
|
TEST(RemoveTopLevelPointerTest, IntermediatePointerUntouched) {
|
|
auto myint = Primitive{Primitive::Kind::Int32};
|
|
auto ptrInt = Pointer{1, myint};
|
|
|
|
auto myclass = Class{0, Class::Kind::Class, "MyClass", 4};
|
|
myclass.members.push_back(Member{ptrInt, "n", 0});
|
|
|
|
test(RemoveTopLevelPointer::createPass(), {myclass}, R"(
|
|
[0] Class: MyClass (size: 4)
|
|
Member: n (offset: 0)
|
|
[1] Pointer
|
|
Primitive: int32_t
|
|
)");
|
|
}
|