1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Add test for fallback decoder overwrite

LegacyDifficultyCalculatorBeatmapDecoder was registered as a fallback
decoder in commit ffde389 for future use in the server-side difficulty
calculation components. Due to the pre-existing fallback registrations
this causes a runtime crash when the diffcalc components are started.
Add a test reproducing this scenario to prevent the issue from
resurfacing in the future.
This commit is contained in:
Bartłomiej Dach 2019-10-04 17:00:51 +02:00
parent 5098cfe556
commit 76c74719a4

View File

@ -591,5 +591,27 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.Throws<IOException>(() => Decoder.GetDecoder<Beatmap>(stream));
}
}
[Test]
public void TestAllowFallbackDecoderOverwrite()
{
Decoder<Beatmap> decoder = null;
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
using (var stream = new LineBufferedReader(resStream))
{
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
}
Assert.DoesNotThrow(LegacyDifficultyCalculatorBeatmapDecoder.Register);
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
using (var stream = new LineBufferedReader(resStream))
{
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
Assert.IsInstanceOf<LegacyDifficultyCalculatorBeatmapDecoder>(decoder);
}
}
}
}