mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Fix unions with base types
This commit is contained in:
parent
e6cbf0509b
commit
f9d5b58102
3 changed files with 17 additions and 4 deletions
|
@ -29,6 +29,12 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Union]
|
||||
struct UnionD : UnionC
|
||||
{
|
||||
public int16 mInt16;
|
||||
}
|
||||
|
||||
[Test]
|
||||
static void TestBasics()
|
||||
{
|
||||
|
@ -41,6 +47,13 @@ namespace Tests
|
|||
*((float*)&ub.mInt32) = 1.2f;
|
||||
Test.Assert(ub.mFloat == 1.2f);
|
||||
Test.Assert(sizeof(UnionB) == 4);
|
||||
|
||||
UnionD ud = .();
|
||||
ud.mInt32 = 123;
|
||||
ud.mInt16 = 234;
|
||||
Test.Assert(sizeof(UnionD) == 6);
|
||||
Test.Assert(alignof(UnionD) == 4);
|
||||
Test.Assert(((int16*)&ud)[3] == 234);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue