Core + binary enumerator
This commit is contained in:
commit
0cbce3c165
8 changed files with 192 additions and 0 deletions
42
test/Nyanbyte.Sysnya.CoreTests/Binary/BinaryReaderTests.cs
Normal file
42
test/Nyanbyte.Sysnya.CoreTests/Binary/BinaryReaderTests.cs
Normal 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);
|
||||
}
|
||||
}
|
|
@ -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>
|
1
test/Nyanbyte.Sysnya.CoreTests/Usings.cs
Normal file
1
test/Nyanbyte.Sysnya.CoreTests/Usings.cs
Normal file
|
@ -0,0 +1 @@
|
|||
global using Xunit;
|
Loading…
Add table
Add a link
Reference in a new issue