1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Add some extra text coverage against potential emoji-to-link misparses

This commit is contained in:
Bartłomiej Dach 2023-07-13 20:49:34 +02:00
parent 71351d8982
commit 4859b8c994
No known key found for this signature in database
2 changed files with 9 additions and 0 deletions

View File

@ -510,6 +510,14 @@ namespace osu.Game.Tests.Chat
Assert.AreEqual(result.Links.Count, 0); Assert.AreEqual(result.Links.Count, 0);
} }
[Test]
public void TestEmojiWithSuccessiveParens()
{
Message result = MessageFormatter.FormatMessage(new Message { Content = "\uD83D\uDE10(let's hope this doesn't accidentally turn into a link)" });
Assert.AreEqual("[emoji](let's hope this doesn't accidentally turn into a link)", result.DisplayContent);
Assert.AreEqual(result.Links.Count, 0);
}
[Test] [Test]
public void TestAbsoluteExternalLinks() public void TestAbsoluteExternalLinks()
{ {

View File

@ -89,6 +89,7 @@ namespace osu.Game.Tests.Visual.Online
addMessageWithChecks($"Join my {OsuGameBase.OSU_PROTOCOL}chan/#english.", 1, expectedActions: LinkAction.OpenChannel); addMessageWithChecks($"Join my {OsuGameBase.OSU_PROTOCOL}chan/#english.", 1, expectedActions: LinkAction.OpenChannel);
addMessageWithChecks("Join my #english or #japanese channels.", 2, expectedActions: new[] { LinkAction.OpenChannel, LinkAction.OpenChannel }); addMessageWithChecks("Join my #english or #japanese channels.", 2, expectedActions: new[] { LinkAction.OpenChannel, LinkAction.OpenChannel });
addMessageWithChecks("Join my #english or #nonexistent #hashtag channels.", 1, expectedActions: LinkAction.OpenChannel); addMessageWithChecks("Join my #english or #nonexistent #hashtag channels.", 1, expectedActions: LinkAction.OpenChannel);
addMessageWithChecks("Hello world\uD83D\uDE12(<--This is an emoji). There are more:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20");
void addMessageWithChecks(string text, int linkAmount = 0, bool isAction = false, bool isImportant = false, params LinkAction[] expectedActions) void addMessageWithChecks(string text, int linkAmount = 0, bool isAction = false, bool isImportant = false, params LinkAction[] expectedActions)
{ {