1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 05:17:25 +08:00
osu-lazer/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs

70 lines
2.5 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using System;
using System.Collections.Generic;
using NUnit.Framework;
2020-01-09 12:43:44 +08:00
using osu.Framework.Utils;
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Rulesets.Taiko.Tests
{
[TestFixture]
public class TaikoBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
2018-04-13 17:19:50 +08:00
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
[NonParallelizable]
[TestCase("basic")]
[TestCase("slider-generating-drumroll")]
[TestCase("sample-to-type-conversions")]
2020-07-16 00:20:32 +08:00
[TestCase("slider-conversion-v6")]
[TestCase("slider-conversion-v14")]
2021-01-12 16:49:18 +08:00
[TestCase("slider-generating-drumroll-2")]
2019-08-05 16:02:28 +08:00
public void Test(string name) => base.Test(name);
2018-04-13 17:19:50 +08:00
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
{
yield return new ConvertValue
{
StartTime = hitObject.StartTime,
EndTime = hitObject.GetEndTime(),
IsRim = (hitObject as Hit)?.Type == HitType.Rim,
IsCentre = (hitObject as Hit)?.Type == HitType.Centre,
2018-04-13 17:19:50 +08:00
IsDrumRoll = hitObject is DrumRoll,
IsSwell = hitObject is Swell,
2020-12-15 04:46:02 +08:00
IsStrong = (hitObject as TaikoStrongableHitObject)?.IsStrong == true
2018-04-13 17:19:50 +08:00
};
}
protected override Ruleset CreateRuleset() => new TaikoRuleset();
2018-04-13 17:19:50 +08:00
}
public struct ConvertValue : IEquatable<ConvertValue>
2018-04-13 17:19:50 +08:00
{
/// <summary>
/// A sane value to account for osu!stable using ints everywhere.
2018-04-13 17:19:50 +08:00
/// </summary>
private const float conversion_lenience = 2;
public double StartTime;
public double EndTime;
public bool IsRim;
public bool IsCentre;
public bool IsDrumRoll;
public bool IsSwell;
public bool IsStrong;
public bool Equals(ConvertValue other)
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
&& IsRim == other.IsRim
&& IsCentre == other.IsCentre
&& IsDrumRoll == other.IsDrumRoll
&& IsSwell == other.IsSwell
&& IsStrong == other.IsStrong;
}
}