mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:52:57 +08:00
Add test coverage of int match failures
This commit is contained in:
parent
bb9123eecd
commit
3799493536
@ -24,8 +24,10 @@ namespace osu.Game.Tests.Chat
|
|||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://osu.ppy.sh/beatmapsets/123#osu/456")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://osu.ppy.sh/beatmapsets/123#osu/456")]
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://osu.ppy.sh/beatmapsets/123#osu/456?whatever")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://osu.ppy.sh/beatmapsets/123#osu/456?whatever")]
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://osu.ppy.sh/beatmapsets/123/456")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://osu.ppy.sh/beatmapsets/123/456")]
|
||||||
|
[TestCase(LinkAction.External, null, "https://osu.ppy.sh/beatmapsets/abc/def")]
|
||||||
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://osu.ppy.sh/beatmapsets/123")]
|
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://osu.ppy.sh/beatmapsets/123")]
|
||||||
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://osu.ppy.sh/beatmapsets/123/whatever")]
|
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://osu.ppy.sh/beatmapsets/123/whatever")]
|
||||||
|
[TestCase(LinkAction.External, null, "https://osu.ppy.sh/beatmapsets/abc")]
|
||||||
public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
|
public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
|
||||||
{
|
{
|
||||||
Message result = MessageFormatter.FormatMessage(new Message { Content = link });
|
Message result = MessageFormatter.FormatMessage(new Message { Content = link });
|
||||||
@ -34,6 +36,8 @@ namespace osu.Game.Tests.Chat
|
|||||||
Assert.AreEqual(1, result.Links.Count);
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
Assert.AreEqual(expectedAction, result.Links[0].Action);
|
Assert.AreEqual(expectedAction, result.Links[0].Action);
|
||||||
Assert.AreEqual(expectedArg, result.Links[0].Argument);
|
Assert.AreEqual(expectedArg, result.Links[0].Argument);
|
||||||
|
if (expectedAction == LinkAction.External)
|
||||||
|
Assert.AreEqual(link, result.Links[0].Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -146,7 +146,10 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
// https://osu.ppy.sh/beatmapsets/1154158#whatever
|
// https://osu.ppy.sh/beatmapsets/1154158#whatever
|
||||||
string trimmed = mainArg.Split('#').First();
|
string trimmed = mainArg.Split('#').First();
|
||||||
return new LinkDetails(LinkAction.OpenBeatmapSet, trimmed);
|
if (int.TryParse(trimmed, out id))
|
||||||
|
return new LinkDetails(LinkAction.OpenBeatmapSet, id.ToString());
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "u":
|
case "u":
|
||||||
|
Loading…
Reference in New Issue
Block a user