Core + binary enumerator

This commit is contained in:
femsci 2023-11-14 15:42:11 +01:00
commit 0cbce3c165
Signed by: femsci
GPG key ID: 08F7911F0E650C67
8 changed files with 192 additions and 0 deletions

View file

@ -0,0 +1,42 @@
using Nyanbyte.Sysnya.Binary;
namespace Nyanbyte.Sysnya.CoreTests.Binary;
public class BinaryReaderTests
{
[Fact]
public void BinaryEnumeratorReadTestsBigEndian()
{
// Given
byte[] memory = { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
BinaryEnumerator reader = new(memory, true);
// When
reader.ReadInt32(out int valA);
reader.ReadInt32(out int valB);
reader.ReadInt64(out long valC);
// Then
Assert.Equal(0x1, valA);
Assert.Equal(0x1000000, valB);
Assert.Equal(0x1, valC);
}
[Fact]
public void BinaryEnumeratorReadTestsLittleEndian()
{
// Given
byte[] memory = { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
BinaryEnumerator reader = new(memory, false);
// When
reader.ReadInt32(out int valA);
reader.ReadInt32(out int valB);
reader.ReadInt64(out long valC);
// Then
Assert.Equal(0x1000000, valA);
Assert.Equal(0x1, valB);
Assert.Equal(0x100000000000000, valC);
}
}

View file

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Nyanbyte.Sysnya\Nyanbyte.Sysnya.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1 @@
global using Xunit;