Skip to content

Commit

Permalink
implemented new usmap versions
Browse files Browse the repository at this point in the history
  • Loading branch information
NotOfficer committed May 24, 2024
1 parent faa3376 commit d25203e
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 52 deletions.
Binary file added src/Usmap.NET.Tests/TestFiles/br2.usmap
Binary file not shown.
Binary file added src/Usmap.NET.Tests/TestFiles/oo2.usmap
Binary file not shown.
Binary file added src/Usmap.NET.Tests/TestFiles/xx2.usmap
Binary file not shown.
126 changes: 123 additions & 3 deletions src/Usmap.NET.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ public class Tests
/*private const int ExpectedSchemas = 13890;
private const int ExpectedEnums = 2367;
private const int ExpectedNames = 74908;*/

private const int ExpectedSchemas = 28697;
private const int ExpectedEnums = 4391;
private const int ExpectedNames = 141495;

private const int ExpectedSchemasV3 = 29520;
private const int ExpectedEnumsV3 = 4484;
private const int ExpectedNamesV3 = 144915;

private readonly string _uncompressedUsmapPath;
private readonly string _brotliCompressedUsmapPath;
private readonly string _oodleCompressedUsmapPath;

private readonly string _uncompressedUsmapV3Path;
private readonly string _brotliCompressedUsmapV3Path;
private readonly string _oodleCompressedUsmapV3Path;

public Tests()
{
var currentDir = Directory.GetCurrentDirectory();
Expand All @@ -32,10 +41,14 @@ public Tests()
_uncompressedUsmapPath = Path.Combine(testFilesDir, "xx1.usmap");
_brotliCompressedUsmapPath = Path.Combine(testFilesDir, "br1.usmap");
_oodleCompressedUsmapPath = Path.Combine(testFilesDir, "oo1.usmap");

_uncompressedUsmapV3Path = Path.Combine(testFilesDir, "xx2.usmap");
_brotliCompressedUsmapV3Path = Path.Combine(testFilesDir, "br2.usmap");
_oodleCompressedUsmapV3Path = Path.Combine(testFilesDir, "oo2.usmap");
}

[Fact]
public void ParseUncompressedUsmapFromFile()
public void ParseUncompressedFromFile()
{
var usmap = new Usmap(_uncompressedUsmapPath);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Expand All @@ -45,7 +58,7 @@ public void ParseUncompressedUsmapFromFile()
}

[Fact]
public void ParseUncompressedUsmapFromStream()
public void ParseUncompressedFromStream()
{
var usmap = new Usmap(File.OpenRead(_uncompressedUsmapPath));
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Expand All @@ -55,7 +68,7 @@ public void ParseUncompressedUsmapFromStream()
}

[Fact]
public void ParseUncompressedUsmapFromBuffer()
public void ParseUncompressedFromBuffer()
{
var buffer = File.ReadAllBytes(_uncompressedUsmapPath);
var usmap = new Usmap(buffer);
Expand Down Expand Up @@ -138,4 +151,111 @@ public void ParseOodleCompressedFromBuffer()
Assert.Equal(ExpectedNames, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

// v3

[Fact]
public void ParseUncompressedV3FromFile()
{
var usmap = new Usmap(_uncompressedUsmapV3Path);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseUncompressedV3FromStream()
{
var usmap = new Usmap(File.OpenRead(_uncompressedUsmapV3Path));
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseUncompressedV3FromBuffer()
{
var buffer = File.ReadAllBytes(_uncompressedUsmapV3Path);
var usmap = new Usmap(buffer);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseBrotliCompressedV3FromFile()
{
var usmap = new Usmap(_brotliCompressedUsmapV3Path);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseBrotliCompressedV3FromStream()
{
var usmap = new Usmap(File.OpenRead(_brotliCompressedUsmapV3Path));
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseBrotliCompressedV3FromBuffer()
{
var buffer = File.ReadAllBytes(_brotliCompressedUsmapV3Path);
var usmap = new Usmap(buffer);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseOodleCompressedV3FromFile()
{
var options = new UsmapOptions
{
Oodle = OodleInstance
};
var usmap = new Usmap(_oodleCompressedUsmapV3Path, options);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseOodleCompressedV3FromStream()
{
var options = new UsmapOptions
{
Oodle = OodleInstance
};
var usmap = new Usmap(File.OpenRead(_oodleCompressedUsmapV3Path), options);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}

[Fact]
public void ParseOodleCompressedV3FromBuffer()
{
var buffer = File.ReadAllBytes(_oodleCompressedUsmapV3Path);
var options = new UsmapOptions
{
Oodle = OodleInstance
};
var usmap = new Usmap(buffer, options);
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
}
}
15 changes: 12 additions & 3 deletions src/Usmap.NET.Tests/Usmap.NET.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -31,18 +31,27 @@
<None Update="TestFiles\br1.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\br2.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\oo.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\oo1.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\oo2.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\xx.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\xx1.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\xx2.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion src/Usmap.NET/EUsmapCompressionMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public enum EUsmapCompressionMethod : byte
Oodle,
/// <summary/>
Brotli,
/// <summary/>
ZStandard,

/// <summary/>
MaxPlusOne,
/// <summary/>
Max = MaxPlusOne - 1,
/// <summary/>
Unknown = byte.MaxValue
Unknown = 0xFF
}
14 changes: 13 additions & 1 deletion src/Usmap.NET/EUsmapVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ public enum EUsmapVersion : byte
{
/// <summary/>
Initial,

/// <summary>
/// Adds package versioning to aid with compatibility
/// </summary>
PackageVersioning,
/// <summary>
/// Adds support for 16-bit wide name-lengths (ushort/uint16)
/// </summary>
LongFName,
/// <summary>
/// Adds support for enums with more than 255 values
/// </summary>
LargeEnums,

/// <summary/>
LatestPlusOne,
/// <summary/>
Expand Down
8 changes: 4 additions & 4 deletions src/Usmap.NET/Usmap.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<!--<PackageIcon>icon.png</PackageIcon>-->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyVersion>2.0.2.0</AssemblyVersion>
<FileVersion>2.0.2.0</FileVersion>
<Version>2.0.2</Version>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<FileVersion>2.1.0.0</FileVersion>
<Version>2.1.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -32,7 +32,7 @@

<ItemGroup>
<PackageReference Include="GenericReader" Version="2.1.2" />
<PackageReference Include="NetEscapades.EnumGenerators" Version="1.0.0-beta08" PrivateAssets="all" />
<PackageReference Include="NetEscapades.EnumGenerators" Version="1.0.0-beta09" PrivateAssets="all" />
<PackageReference Include="Oodle.NET" Version="2.0.2" />
</ItemGroup>

Expand Down
Loading

0 comments on commit d25203e

Please sign in to comment.