-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from puff/fix/enum-marshalling
Fix marshalling enums in CliMarshaller
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/Platforms/Echo.Platforms.AsmResolver.Tests/Emulation/CliMarshallerTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using Echo.Memory; | ||
using Echo.Platforms.AsmResolver.Emulation; | ||
using Echo.Platforms.AsmResolver.Emulation.Stack; | ||
using Echo.Platforms.AsmResolver.Tests.Mock; | ||
using Mocks; | ||
using Xunit; | ||
|
||
namespace Echo.Platforms.AsmResolver.Tests.Emulation; | ||
|
||
public class CliMarshallerTest : IClassFixture<MockModuleFixture> | ||
{ | ||
private readonly MockModuleFixture _fixture; | ||
private readonly ValueFactory _factory; | ||
private readonly CliMarshaller _marshaller; | ||
|
||
public CliMarshallerTest(MockModuleFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
_factory = new ValueFactory(_fixture.MockModule, false); | ||
_marshaller = new CliMarshaller(_factory); | ||
} | ||
|
||
[Fact] | ||
public void MarshalEnumToStackShouldMarshalAsInteger() | ||
{ | ||
var int32EnumType = _fixture.MockModule.TopLevelTypes.First(x => x.Name == nameof(Int32Enum)); | ||
var marshalledEnum = _marshaller.ToCliValue(new BitVector(0x1337), int32EnumType.ToTypeSignature()); | ||
|
||
Assert.Equal(StackSlotTypeHint.Integer, marshalledEnum.TypeHint); | ||
} | ||
} |