object-introspection/test/test_remove_top_level_pointer.cpp
Alastair Robertson ff31971bd3 Printer: Use NodeIds for stable IDs when printing graphs
This removes Printer's legacy behaviour of generating an ID for each
node as it gets printed. This old method meant that if new nodes were
added to or removed from a graph, every ID after the new/removed node
would change.

Now IDs are stable so it is easier to follow specific nodes through
multiple transformation passes in CodeGen.
2023-08-16 12:19:14 +01:00

39 lines
923 B
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) {
test(RemoveTopLevelPointer::createPass(), R"(
[0] Pointer
[1] Class: MyClass (size: 4)
Member: n (offset: 0)
Primitive: int32_t
)",
R"(
[1] Class: MyClass (size: 4)
Member: n (offset: 0)
Primitive: int32_t
)");
}
TEST(RemoveTopLevelPointerTest, TopLevelClassUntouched) {
testNoChange(RemoveTopLevelPointer::createPass(), R"(
[0] Class: MyClass (size: 4)
Member: n (offset: 0)
Primitive: int32_t
)");
}
TEST(RemoveTopLevelPointerTest, IntermediatePointerUntouched) {
testNoChange(RemoveTopLevelPointer::createPass(), R"(
[0] Class: MyClass (size: 4)
Member: n (offset: 0)
[1] Pointer
Primitive: int32_t
)");
}