mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
AddPaddingTest: Tests for unions and memberless classes
This commit is contained in:
parent
1e1b319a69
commit
3aa52deb71
@ -55,7 +55,7 @@ TEST(AddPaddingTest, AtEnd) {
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AddPaddingTest, UnionNotPadded) {
|
||||
TEST(AddPaddingTest, UnionBetweenMembers) {
|
||||
auto myclass = Class{0, Class::Kind::Union, "MyUnion", 8};
|
||||
auto myint8 = Primitive{Primitive::Kind::Int8};
|
||||
auto myint64 = Primitive{Primitive::Kind::Int64};
|
||||
@ -71,6 +71,23 @@ TEST(AddPaddingTest, UnionNotPadded) {
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AddPaddingTest, UnionAtEnd) {
|
||||
test(AddPadding::createPass({}), R"(
|
||||
[0] Union: MyUnion (size: 16)
|
||||
Member: n1 (offset: 0)
|
||||
Primitive: int64_t
|
||||
Member: n2 (offset: 0)
|
||||
Primitive: int8_t
|
||||
)",
|
||||
R"(
|
||||
[0] Union: MyUnion (size: 16)
|
||||
Member: n1 (offset: 0)
|
||||
Primitive: int64_t
|
||||
Member: n2 (offset: 0)
|
||||
Primitive: int8_t
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AddPaddingTest, Bitfields) {
|
||||
auto myclass = Class{0, Class::Kind::Class, "MyClass", 16};
|
||||
auto myint64 = Primitive{Primitive::Kind::Int64};
|
||||
@ -147,4 +164,28 @@ TEST(AddPaddingTest, CodeGenCompatibility) {
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AddPaddingTest, EmptyClass) {
|
||||
testNoChange(AddPadding::createPass({}), R"(
|
||||
[0] Class: MyClass (size: 0)
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AddPaddingTest, MemberlessClass) {
|
||||
test(AddPadding::createPass({}), R"(
|
||||
[0] Class: MyClass (size: 12)
|
||||
)",
|
||||
R"(
|
||||
[0] Class: MyClass (size: 12)
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AddPaddingTest, MemberlessUnion) {
|
||||
test(AddPadding::createPass({}), R"(
|
||||
[0] Union: MyUnion (size: 16)
|
||||
)",
|
||||
R"(
|
||||
[0] Union: MyUnion (size: 16)
|
||||
)");
|
||||
}
|
||||
|
||||
// TODO test we follow class members, templates, children
|
||||
|
Loading…
Reference in New Issue
Block a user