Add unit test for duplicate firmware filenames
This commit is contained in:
parent
69b61b574d
commit
384b6f17a7
|
@ -1,3 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.CollectionExtensions;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -20,5 +24,28 @@ namespace BizHawk.Tests.Emulation.Common
|
|||
foreach (var hash in FirmwareDatabase.FirmwareFilesByHash.Keys) CustomAssert(hash);
|
||||
foreach (var fo in FirmwareDatabase.FirmwareOptions) CustomAssert(fo.Hash);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CheckOrganizeFilenames()
|
||||
{
|
||||
SortedList<string, FirmwareFile> seen = new();
|
||||
List<FirmwareFile> dupes = new();
|
||||
foreach (var ff in FirmwareDatabase.FirmwareFilesByHash.Values)
|
||||
{
|
||||
if (seen.TryGetValue(ff.RecommendedName, out var ffExisting))
|
||||
{
|
||||
dupes.Add(ffExisting);
|
||||
dupes.Add(ff);
|
||||
}
|
||||
else
|
||||
{
|
||||
seen.Add(ff.RecommendedName, ff);
|
||||
}
|
||||
}
|
||||
if (dupes.Count is 0) return;
|
||||
Assert.Fail($"multiple {nameof(FirmwareFile)}s have the same suggested filename (breaks Organize function):\n{
|
||||
string.Join("\n", dupes.Select(static ff => $"\t{ff.RecommendedName} {ff.Hash}").Order())
|
||||
}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue