Skip to content

Commit

Permalink
Merge pull request #2166 from andy840119/fix-deep-clone-the-time-tag
Browse files Browse the repository at this point in the history
Fix deep clone the time tag.
  • Loading branch information
andy840119 authored Jan 17, 2024
2 parents e6b40e8 + 2591298 commit 845fba6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Karaoke.Tests/Asserts/TimeTagAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ public static void ArePropertyEqual(TimeTag expect, TimeTag actually)
{
AreEqual(expect.Index, actually.Index);
AreEqual(expect.Time, actually.Time);
AreEqual(expect.FirstSyllable, actually.FirstSyllable);
AreEqual(expect.RomanizedSyllable, actually.RomanizedSyllable);
}
}
8 changes: 7 additions & 1 deletion osu.Game.Rulesets.Karaoke.Tests/Objects/TimeTagTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ public class TimeTagTest
[Test]
public void TestClone()
{
var timeTag = new TimeTag(new TextIndex(1, TextIndex.IndexState.End), 1000);
var timeTag = new TimeTag(new TextIndex(1, TextIndex.IndexState.End), 1000)
{
FirstSyllable = true,
RomanizedSyllable = "karaoke",
};

var clonedTimeTag = timeTag.DeepClone();

Assert.AreEqual(clonedTimeTag.Index, timeTag.Index);

Assert.AreNotSame(clonedTimeTag.TimeBindable, timeTag.TimeBindable);
Assert.AreEqual(clonedTimeTag.Time, timeTag.Time);
Assert.AreNotSame(clonedTimeTag.FirstSyllable, timeTag.FirstSyllable);
Assert.AreEqual(clonedTimeTag.RomanizedSyllable, timeTag.RomanizedSyllable);
}
}
6 changes: 5 additions & 1 deletion osu.Game.Rulesets.Karaoke/Objects/TimeTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public string? RomanizedSyllable

public TimeTag DeepClone()
{
return new TimeTag(Index, Time);
return new TimeTag(Index, Time)
{
FirstSyllable = FirstSyllable,
RomanizedSyllable = RomanizedSyllable,
};
}
}

0 comments on commit 845fba6

Please sign in to comment.