Skip to content

Commit

Permalink
Deep clone the time-tag should copy the romanization-related property.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Jan 17, 2024
1 parent e6b40e8 commit 0a58d54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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 0a58d54

Please sign in to comment.