1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-18 16:10:26 +02:00
Beef/IDEHelper/Tests/src/Unions.bf
2019-08-23 11:56:54 -07:00

35 lines
488 B
Beef

using System;
namespace Tests
{
class Unions
{
// Not really a union
[Union]
struct UnionA
{
public int32 mInt32;
}
[Union]
struct UnionB
{
public int32 mInt32;
public float mFloat;
}
[Test]
static void TestBasics()
{
UnionA ua = .();
ua.mInt32 = 123;
Test.Assert(sizeof(UnionA) == 4);
UnionB ub = .();
ub.mInt32 = 123;
*((float*)&ub.mInt32) = 1.2f;
Test.Assert(ub.mFloat == 1.2f);
Test.Assert(sizeof(UnionB) == 4);
}
}
}