diff --git a/src/BizHawk.Common/Extensions/CollectionExtensions.cs b/src/BizHawk.Common/Extensions/CollectionExtensions.cs index 10479d83be..f2433be6f5 100644 --- a/src/BizHawk.Common/Extensions/CollectionExtensions.cs +++ b/src/BizHawk.Common/Extensions/CollectionExtensions.cs @@ -168,5 +168,33 @@ namespace BizHawk.Common.CollectionExtensions } return c - list.Count; } + + public static bool IsSortedAsc(this IReadOnlyList list) + where T : IComparable + { + for (int i = 0, e = list.Count - 1; i < e; i++) if (list[i + 1].CompareTo(list[i]) < 0) return false; + return true; + } + + public static bool IsSortedAsc(this ReadOnlySpan span) + where T : IComparable + { + for (int i = 0, e = span.Length - 1; i < e; i++) if (span[i + 1].CompareTo(span[i]) < 0) return false; + return true; + } + + public static bool IsSortedDesc(this IReadOnlyList list) + where T : IComparable + { + for (int i = 0, e = list.Count - 1; i < e; i++) if (list[i + 1].CompareTo(list[i]) > 0) return false; + return true; + } + + public static bool IsSortedDesc(this ReadOnlySpan span) + where T : IComparable + { + for (int i = 0, e = span.Length - 1; i < e; i++) if (span[i + 1].CompareTo(span[i]) > 0) return false; + return true; + } } } diff --git a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.Cases.cs b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.Cases.cs index 70237685b1..7674449719 100644 --- a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.Cases.cs +++ b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.Cases.cs @@ -12,7 +12,7 @@ namespace BizHawk.Tests.Testroms.GB.GambatteSuite { public static readonly GambatteHexStrTestCase Dummy = new("missing_files", new(CoreNames.Gambatte, ConsoleVariant.DMG), string.Empty, string.Empty); - public static readonly IReadOnlyCollection KnownFailures = new[] + public static readonly IReadOnlyList KnownFailures = new[] { "cgbpal_m3.cgbpal_m3end_1_cgb04c_out7 on CGB_C in GBHawk", "cgbpal_m3.cgbpal_m3end_3_cgb04c_out0 on CGB_C in GBHawk", @@ -2952,7 +2952,7 @@ namespace BizHawk.Tests.Testroms.GB.GambatteSuite { public static readonly GambatteRefImageTestCase Dummy = new("missing_files", new(CoreNames.Gambatte, ConsoleVariant.DMG), string.Empty, string.Empty); - public static readonly IReadOnlyCollection KnownFailures = new[] + public static readonly IReadOnlyList KnownFailures = new[] { "bgen.bgoff_bgon_sprite_below_window on CGB_C in SameBoy", "bgen.bgoff_bgon_sprite_below_window on CGB_C in SameBoy (no BIOS)", diff --git a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs index bd576a05c7..a830ae8de6 100644 --- a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs +++ b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs @@ -81,7 +81,10 @@ namespace BizHawk.Tests.Testroms.GB.GambatteSuite [ClassInitialize] public static void BeforeAll(TestContext ctx) - => TestUtils.PrepareDBAndOutput(SUITE_ID); + { + if (!(GambatteHexStrTestCase.KnownFailures.IsSortedAsc() && GambatteHexStrTestCase.KnownFailures.IsSortedAsc())) throw new Exception(SUITE_ID + " known-failing testcase list must be sorted"); + TestUtils.PrepareDBAndOutput(SUITE_ID); + } private static (IReadOnlyList RefImageCases, IReadOnlyList HexStrCases) EnumerateAllCases() { diff --git a/src/BizHawk.Tests.Testroms.GB/GB_GBC/MealybugTearoomTests.cs b/src/BizHawk.Tests.Testroms.GB/GB_GBC/MealybugTearoomTests.cs index a07df6cc97..e1a92c8538 100644 --- a/src/BizHawk.Tests.Testroms.GB/GB_GBC/MealybugTearoomTests.cs +++ b/src/BizHawk.Tests.Testroms.GB/GB_GBC/MealybugTearoomTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using BizHawk.Common.CollectionExtensions; using BizHawk.Common.IOExtensions; using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; @@ -23,7 +24,7 @@ namespace BizHawk.Tests.Testroms.GB { public static readonly MealybugTestCase Dummy = new("missing_files", new(CoreNames.Gambatte, ConsoleVariant.DMG), string.Empty, string.Empty); - public static readonly IReadOnlyCollection KnownFailures = new[] + public static readonly IReadOnlyList KnownFailures = new[] { "m2_win_en_toggle on CGB_C in SameBoy (no BIOS)", "m3_bgp_change on CGB_C in Gambatte", // Gambatte's GBC emulation matches CGB D variant @@ -80,11 +81,11 @@ namespace BizHawk.Tests.Testroms.GB "m3_lcdc_obj_en_change_variant on DMG in SameBoy", // SameBoy emulates DMG-B, but there's no DMG-B-specific expect image for this test, so it should be the same on all DMG revisions? "m3_lcdc_obj_en_change_variant on DMG in SameBoy (no BIOS)", // SameBoy emulates DMG-B, but there's no DMG-B-specific expect image for this test, so it should be the same on all DMG revisions? "m3_lcdc_obj_size_change on CGB_C in GBHawk", + "m3_lcdc_obj_size_change on CGB_C in SameBoy", + "m3_lcdc_obj_size_change on CGB_C in SameBoy (no BIOS)", "m3_lcdc_obj_size_change on DMG in Gambatte", "m3_lcdc_obj_size_change on DMG in Gambatte (no BIOS)", "m3_lcdc_obj_size_change on DMG in GBHawk", - "m3_lcdc_obj_size_change on CGB_C in SameBoy", - "m3_lcdc_obj_size_change on CGB_C in SameBoy (no BIOS)", "m3_lcdc_obj_size_change on DMG in SameBoy", "m3_lcdc_obj_size_change on DMG in SameBoy (no BIOS)", "m3_lcdc_obj_size_change_scx on CGB_C in GBHawk", @@ -260,7 +261,10 @@ namespace BizHawk.Tests.Testroms.GB [ClassInitialize] public static void BeforeAll(TestContext ctx) - => TestUtils.PrepareDBAndOutput(SUITE_ID); + { + if (!MealybugTestCase.KnownFailures.IsSortedAsc()) throw new Exception(SUITE_ID + " known-failing testcase list must be sorted"); + TestUtils.PrepareDBAndOutput(SUITE_ID); + } [DataTestMethod] [MealybugTestData]