Parser tests, part 1

This commit is contained in:
Matt Nadareski
2020-12-20 14:20:03 -08:00
parent 199b8c01af
commit c64d724eb4
13 changed files with 75 additions and 35 deletions

View File

@@ -176,6 +176,7 @@ namespace SabreTools.Core.Tools
case "sha256":
case "sha384":
case "sha512":
case "spamsum":
case "ssv":
case "tsv":
case "txt":

View File

@@ -47,7 +47,7 @@ namespace SabreTools.DatFiles.Formats
string name = string.Empty;
string hash = string.Empty;
// If we have CRC, then it's an SFV file and the name is first are
// If we have CRC, then it's an SFV file and the name is first
if (_hash.HasFlag(Hash.CRC))
{
name = split[0].Replace("*", String.Empty);

View File

@@ -12,43 +12,11 @@
</ItemGroup>
<ItemGroup>
<None Remove="Skippers\a7800.xml" />
<None Remove="Skippers\fds.xml" />
<None Remove="Skippers\lynx.xml" />
<None Remove="Skippers\n64.xml" />
<None Remove="Skippers\nes.xml" />
<None Remove="Skippers\pce.xml" />
<None Remove="Skippers\psid.xml" />
<None Remove="Skippers\snes.xml" />
<None Remove="Skippers\spc.xml" />
<None Remove="Skippers\*" />
</ItemGroup>
<ItemGroup>
<Content Include="Skippers\a7800.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\fds.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\lynx.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\n64.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\nes.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\pce.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\psid.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\snes.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Skippers\spc.xml">
<Content Include="Skippers\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

View File

@@ -0,0 +1,52 @@
using System;
using System.IO;
using SabreTools.DatFiles;
using SabreTools.DatTools;
using Xunit;
namespace SabreTools.Test.DatTools
{
public class ParserTests
{
// TODO: Create files for each of these
// TODO: Ensure that all stress all bits of reading
// TODO: Add total count? Might be a good metric if everything read
[Theory]
[InlineData(null, (DatFormat)0x00)]
//[InlineData(null, DatFormat.Logiqx)]
//[InlineData(null, DatFormat.LogiqxDeprecated)] // Not parsed separately
//[InlineData(null, DatFormat.SoftwareList)]
//[InlineData(null, DatFormat.Listxml)]
//[InlineData(null, DatFormat.OfflineList)]
//[InlineData(null, DatFormat.SabreXML)]
//[InlineData(null, DatFormat.OpenMSX)]
//[InlineData(null, DatFormat.ClrMamePro)]
//[InlineData(null, DatFormat.RomCenter)]
//[InlineData(null, DatFormat.DOSCenter)]
//[InlineData(null, DatFormat.AttractMode)]
//[InlineData(null, DatFormat.MissFile)] // Parsing is not supported
//[InlineData(null, DatFormat.CSV)]
//[InlineData(null, DatFormat.SSV)]
//[InlineData(null, DatFormat.TSV)]
//[InlineData(null, DatFormat.Listrom)]
[InlineData("test-smdb.txt", DatFormat.EverdriveSMDB)]
//[InlineData(null, DatFormat.SabreJSON)]
[InlineData("test-sfv.sfv", DatFormat.RedumpSFV)]
[InlineData("test-md5.md5", DatFormat.RedumpMD5)]
[InlineData("test-sha1.sha1", DatFormat.RedumpSHA1)]
[InlineData("test-sha256.sha256", DatFormat.RedumpSHA256)]
[InlineData("test-sha384.sha384", DatFormat.RedumpSHA384)]
[InlineData("test-sha512.sha512", DatFormat.RedumpSHA512)]
[InlineData("test-spamsum.spamsum", DatFormat.RedumpSpamSum)]
public void CreateAndParseTest(string filename, DatFormat datFormat)
{
// For all filenames, add the local path for test data
if (filename != null)
filename = Path.Combine(Environment.CurrentDirectory, "TestData", filename);
var datFile = Parser.CreateAndParse(filename);
Assert.Equal(datFormat, datFile.Header.DatFormat);
}
}
}

View File

@@ -9,12 +9,23 @@
<ProjectReference Include="..\SabreTools.Core\SabreTools.Core.csproj" />
<ProjectReference Include="..\SabreTools.DatFiles\SabreTools.DatFiles.csproj" />
<ProjectReference Include="..\SabreTools.DatItems\SabreTools.DatItems.csproj" />
<ProjectReference Include="..\SabreTools.DatTools\SabreTools.DatTools.csproj" />
<ProjectReference Include="..\SabreTools.FileTypes\SabreTools.FileTypes.csproj" />
<ProjectReference Include="..\SabreTools.Filtering\SabreTools.Filtering.csproj" />
<ProjectReference Include="..\SabreTools.IO\SabreTools.IO.csproj" />
<ProjectReference Include="..\SabreTools.Skippers\SabreTools.Skippers.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="TestData\*" />
</ItemGroup>
<ItemGroup>
<Content Include="TestData\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />

View File

@@ -0,0 +1 @@
d41d8cd98f00b204e9800998ecf8427e rom.bin

View File

@@ -0,0 +1 @@
rom.bin 00000000

View File

@@ -0,0 +1 @@
da39a3ee5e6b4b0d3255bfef95601890afd80709 rom.bin

View File

@@ -0,0 +1 @@
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad rom.bin

View File

@@ -0,0 +1 @@
cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 rom.bin

View File

@@ -0,0 +1 @@
ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f rom.bin

View File

@@ -0,0 +1 @@
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad test/rom.bin da39a3ee5e6b4b0d3255bfef95601890afd80709 d41d8cd98f00b204e9800998ecf8427e 00000000

View File

@@ -0,0 +1 @@
QXX rom.bin