Skip to content

Commit

Permalink
Remove the un-need utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Dec 27, 2022
1 parent 8e628ac commit 36d2304
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
13 changes: 0 additions & 13 deletions osu.Game.Rulesets.Karaoke.Tests/Utils/EnumUtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Utils
[TestFixture]
public class EnumUtilsTest
{
[Test]
public void TestGetValues()
{
var expected = new[]
{
TestEnum.Enum1,
TestEnum.Enum2,
TestEnum.Enum3
};
var actual = EnumUtils.GetValues<TestEnum>();
Assert.AreEqual(expected, actual);
}

[TestCase(TestEnum.Enum1, TestEnum.Enum3)]
[TestCase(TestEnum.Enum2, TestEnum.Enum1)]
[TestCase(TestEnum.Enum3, TestEnum.Enum2)]
Expand Down
11 changes: 4 additions & 7 deletions osu.Game.Rulesets.Karaoke/Utils/EnumUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ namespace osu.Game.Rulesets.Karaoke.Utils
{
public static class EnumUtils
{
public static T[] GetValues<T>() where T : Enum
=> (T[])Enum.GetValues(typeof(T));
public static T GetPreviousValue<T>(T v) where T : struct, Enum
=> Enum.GetValues<T>().Concat(new[] { default(T)! }).Reverse().SkipWhile(e => !EqualityComparer<T>.Default.Equals(v, e)).Skip(1).First();

public static T GetPreviousValue<T>(T v) where T : Enum
=> GetValues<T>().Concat(new[] { default(T)! }).Reverse().SkipWhile(e => !EqualityComparer<T>.Default.Equals(v, e)).Skip(1).First();

public static T GetNextValue<T>(T v) where T : Enum
=> GetValues<T>().Concat(new[] { default(T)! }).SkipWhile(e => !EqualityComparer<T>.Default.Equals(v, e)).Skip(1).First();
public static T GetNextValue<T>(T v) where T : struct, Enum
=> Enum.GetValues<T>().Concat(new[] { default(T)! }).SkipWhile(e => !EqualityComparer<T>.Default.Equals(v, e)).Skip(1).First();

public static T Casting<T>(Enum mode)
=> (T)(object)mode;
Expand Down

0 comments on commit 36d2304

Please sign in to comment.