mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-25 19:18:01 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
35
IDEHelper/Tests/src/Unions.bf
Normal file
35
IDEHelper/Tests/src/Unions.bf
Normal file
|
@ -0,0 +1,35 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue