mirror of https://github.com/ppy/osu
Add a catch beatmap conversion testcase
This commit is contained in:
parent
573d6d1b5f
commit
bae598b9f4
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
|
{
|
||||||
|
public class CatchBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
||||||
|
{
|
||||||
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
|
||||||
|
|
||||||
|
[TestCase(875945)]
|
||||||
|
public new void Test(int beatmapId)
|
||||||
|
{
|
||||||
|
base.Test(beatmapId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
||||||
|
{
|
||||||
|
if (hitObject is JuiceStream stream)
|
||||||
|
{
|
||||||
|
foreach (var nested in stream.NestedHitObjects)
|
||||||
|
{
|
||||||
|
yield return new ConvertValue
|
||||||
|
{
|
||||||
|
StartTime = nested.StartTime,
|
||||||
|
Position = ((CatchHitObject)nested).X * CatchPlayfield.BASE_WIDTH
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield return new ConvertValue
|
||||||
|
{
|
||||||
|
StartTime = hitObject.StartTime,
|
||||||
|
Position = ((CatchHitObject)hitObject).X * CatchPlayfield.BASE_WIDTH
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ITestableBeatmapConverter CreateConverter(Beatmap beatmap) => new CatchBeatmapConverter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ConvertValue : IEquatable<ConvertValue>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A sane value to account for osu!stable using ints everwhere.
|
||||||
|
/// </summary>
|
||||||
|
private const float conversion_lenience = 2;
|
||||||
|
|
||||||
|
public double StartTime;
|
||||||
|
public float Position;
|
||||||
|
|
||||||
|
public bool Equals(ConvertValue other)
|
||||||
|
=> Precision.AlmostEquals(StartTime, other.StartTime)
|
||||||
|
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience);
|
||||||
|
}
|
||||||
|
}
|
|
@ -95,6 +95,7 @@
|
||||||
<Compile Include="Objects\Fruit.cs" />
|
<Compile Include="Objects\Fruit.cs" />
|
||||||
<Compile Include="Objects\TinyDroplet.cs" />
|
<Compile Include="Objects\TinyDroplet.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Tests\CatchBeatmapConversionTest.cs" />
|
||||||
<Compile Include="Tests\TestCaseBananaShower.cs" />
|
<Compile Include="Tests\TestCaseBananaShower.cs" />
|
||||||
<Compile Include="Tests\TestCaseCatcherArea.cs" />
|
<Compile Include="Tests\TestCaseCatcherArea.cs" />
|
||||||
<Compile Include="Tests\TestCaseCatchStacker.cs" />
|
<Compile Include="Tests\TestCaseCatchStacker.cs" />
|
||||||
|
@ -128,6 +129,10 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\Testing\Beatmaps\875945-expected-conversion.json" />
|
||||||
|
<EmbeddedResource Include="Resources\Testing\Beatmaps\875945.osu" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets" Condition="Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" />
|
<Import Project="$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets" Condition="Exists('$(SolutionDir)\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.8\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
|
Loading…
Reference in New Issue