Parser tests, part 2

This commit is contained in:
Matt Nadareski
2020-12-20 15:09:36 -08:00
parent c64d724eb4
commit da5d1631c6
7 changed files with 118 additions and 29 deletions

View File

@@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats
// If we have the beginning of a game, set the name of the game
else if (line.StartsWith("ROMs required for"))
{
gamename = Regex.Match(line, @"^ROMs required for \S*? string.Empty(.*?)string.Empty\.").Groups[1].Value;
gamename = Regex.Match(line, @"^ROMs required for \S*? ""(.*?)""\.").Groups[1].Value;
}
// If we have a machine with no required roms (usually internal devices), skip it

View File

@@ -230,7 +230,7 @@ namespace SabreTools.DatTools
else if (first.Contains("doscenter"))
return DatFormat.DOSCenter;
else if (first.Contains("#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra"))
else if (first.Contains("#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra".ToLowerInvariant()))
return DatFormat.AttractMode;
else

View File

@@ -13,33 +13,33 @@ namespace SabreTools.Test.DatTools
// 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)
[InlineData(null, (DatFormat)0x00, 0)]
//[InlineData(null, DatFormat.Logiqx, 0)]
//[InlineData(null, DatFormat.LogiqxDeprecated, 0)] // Not parsed separately
//[InlineData(null, DatFormat.SoftwareList, 0)]
//[InlineData(null, DatFormat.Listxml, 0)]
//[InlineData(null, DatFormat.OfflineList, 0)]
//[InlineData(null, DatFormat.SabreXML, 0)]
[InlineData("test-openmsx.xml", DatFormat.OpenMSX, 3)]
[InlineData("test-cmp.dat", DatFormat.ClrMamePro, 6)]
//[InlineData(null, DatFormat.RomCenter, 0)]
//[InlineData(null, DatFormat.DOSCenter, 0)]
[InlineData("test-attractmode.txt", DatFormat.AttractMode, 1)]
//[InlineData(null, DatFormat.MissFile, 0)] // Parsing is not supported
//[InlineData(null, DatFormat.CSV, 0)]
//[InlineData(null, DatFormat.SSV, 0)]
//[InlineData(null, DatFormat.TSV, 0)]
[InlineData("test-listrom.txt", DatFormat.Listrom, 6)]
[InlineData("test-smdb.txt", DatFormat.EverdriveSMDB, 1)]
//[InlineData(null, DatFormat.SabreJSON, 0)]
[InlineData("test-sfv.sfv", DatFormat.RedumpSFV, 1)]
[InlineData("test-md5.md5", DatFormat.RedumpMD5, 1)]
[InlineData("test-sha1.sha1", DatFormat.RedumpSHA1, 1)]
[InlineData("test-sha256.sha256", DatFormat.RedumpSHA256, 1)]
[InlineData("test-sha384.sha384", DatFormat.RedumpSHA384, 1)]
[InlineData("test-sha512.sha512", DatFormat.RedumpSHA512, 1)]
[InlineData("test-spamsum.spamsum", DatFormat.RedumpSpamSum, 1)]
public void CreateAndParseTest(string filename, DatFormat datFormat, int totalCount)
{
// For all filenames, add the local path for test data
if (filename != null)
@@ -47,6 +47,7 @@ namespace SabreTools.Test.DatTools
var datFile = Parser.CreateAndParse(filename);
Assert.Equal(datFormat, datFile.Header.DatFormat);
Assert.Equal(totalCount, datFile.Items.TotalCount);
}
}
}

View File

@@ -0,0 +1,2 @@
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
game-1;desc-1;MAME;game-2;1990;Big Manufacturer;Game;4;0;6-button;Verified;1;Horizontal;Game!;Game! (v2);Glitchy;6

View File

@@ -0,0 +1,48 @@
clrmamepro (
name "Internal DAT Name"
description "Internal DAT Name"
rootdir "root"
category "games"
version "1.0"
date "1900-01-01"
author "Unknown"
email "email@email.email"
homepage "localhost"
url "127.0.0.1"
comment "Not real data, sorry"
header "match.xml"
type "SuperDAT"
forcemerging "split"
forcezipping "zip"
forcepacking "yes"
)
set (
name "game1"
description "Game! 1.0"
year "1980"
manufacturer "Manufacturer"
category "Arcade"
cloneof "game2"
romof "game2"
sampleof "genpin"
rom ( name "rom.bin" size 1024 crc DEADBEEF md5 b41d8cd98f00b204e9800998ecf8427e sha1 aa39a3ee5e6b4b0d3255bfef95601890afd80709 sha256 aa7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad sha384 cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a8 sha512 ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49d spamsum QXXY status baddump date "1980-01-01" )
disk ( name "disk" md5 b41d8cd98f00b204e9800998ecf8427e sha1 aa39a3ee5e6b4b0d3255bfef95601890afd80709 status baddump )
media ( name "media" md5 b41d8cd98f00b204e9800998ecf8427e sha1 aa39a3ee5e6b4b0d3255bfef95601890afd80709 sha256 aa7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad spamsum QXXY )
)
game (
name "game2"
release ( name "Release" date "1980-01-01" default yes region World language English )
)
machine (
name "game3"
biosset ( name "Universal BIOS" default yes description "Worldwide" )
)
resource (
name "genpin"
sample ( name "genericsample" )
)

View File

@@ -0,0 +1,8 @@
ROMs required for driver "game".
Name Size Checksum
diskname SHA1(a257c456d31681068ed5caa1f1fb2b51da4826db)
baddisk BAD SHA1(abcdc456d31681068ed5caa1f1fb2b51da4826db) BAD_DUMP
goodrom.bin 2048 CRC(8f68533e) SHA1(b257c556d31691068ed5c991f1fb2b51da4826db)
missingdisk NO GOOD DUMP KNOWN
badrom.bin 32 BAD CRC(000000b0) SHA1(bb0bb62365402543e3154b9a77be9c75010e6abc) BAD_DUMP
missingrom.bin 108 NO GOOD DUMP KNOWN

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE softwaredb SYSTEM "softwaredb1.dtd">
<softwaredb timestamp="1608157456">
<!-- Credits -->
<![CDATA[
The softwaredb.xml file contains information about rom mapper types
- Copyright 2003 Nicolas Beyaert (Initial Database)
- Copyright 2004-2013 BlueMSX Team
- Copyright 2005-2020 openMSX Team
- Generation MSXIDs by www.generation-msx.nl
- Thanks go out to:
- - Generation MSX/Sylvester for the incredible source of information
- p_gimeno and diedel for their help adding and valdiating ROM additions
- GDX for additional ROM info and validations and corrections
]]>
<software>
<title>Game Name</title>
<genmsxid>0001</genmsxid>
<system>MSX1</system>
<company>Manufacturer</company>
<year>19xx</year>
<country>World</country>
<dump><rom><hash>7acd00c9053fbf7f7d698485759d170a483b123d</hash><start>0x8000</start><type>ASCII8</type><remark>Comment Here</remark></rom></dump>
<dump><megarom><hash>da58f56d4b1660bc36d74bfb29776ef8ec61a831</hash><start>0x4000</start><type>ASCII16</type><remark>Comment Too</remark></megarom></dump>
<dump><original value="true">Good</original><boot>LOAD(8)</boot><sccpluscart><type>KonamiSCC</type><hash>afb1aef44a67cf7c9232f8a1c8587c66dd820caa</hash><remark>Comment Three</remark></sccpluscart></dump>
</software>