mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add diff=
support for more advanced usages
This commit is contained in:
parent
6865d8894d
commit
fcb366af4d
@ -399,6 +399,10 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
[TestCase("[diff ]with [[ brackets]]]]", new[] { 4 })]
|
||||
[TestCase("[Diff in title]", new int[] { })]
|
||||
[TestCase("[Diff in diff]", new int[] { 6 })]
|
||||
[TestCase("diff=Diff", new[] { 0, 1, 3, 4, 6 })]
|
||||
[TestCase("diff=Diff1", new[] { 0 })]
|
||||
[TestCase("diff=\"Diff\"", new[] { 3, 4, 6 })]
|
||||
[TestCase("diff=!\"Diff\"", new int[] {})]
|
||||
public void TestDifficultySearch(string query, int[] expectedBeatmapIndexes)
|
||||
{
|
||||
var carouselBeatmaps = (((string title, string difficultyName)[])new[]
|
||||
@ -424,15 +428,11 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
FilterQueryParser.ApplyQueries(criteria, query);
|
||||
carouselBeatmaps.ForEach(b => b.Filter(criteria));
|
||||
|
||||
Assert.That(carouselBeatmaps.All(b =>
|
||||
{
|
||||
int index = carouselBeatmaps.IndexOf(b);
|
||||
int[] visibleBeatmaps = carouselBeatmaps
|
||||
.Where(b => !b.Filtered.Value)
|
||||
.Select(b => carouselBeatmaps.IndexOf(b)).ToArray();
|
||||
|
||||
bool shouldBeVisible = expectedBeatmapIndexes.Contains(index);
|
||||
bool isVisible = !b.Filtered.Value;
|
||||
|
||||
return isVisible == shouldBeVisible;
|
||||
}));
|
||||
Assert.That(visibleBeatmaps, Is.EqualTo(expectedBeatmapIndexes));
|
||||
}
|
||||
|
||||
private class CustomFilterCriteria : IRulesetFilterCriteria
|
||||
|
@ -76,6 +76,9 @@ namespace osu.Game.Screens.Select
|
||||
case "title":
|
||||
return TryUpdateCriteriaText(ref criteria.Title, op, value);
|
||||
|
||||
case "diff":
|
||||
return TryUpdateCriteriaText(ref criteria.DifficultyName, op, value);
|
||||
|
||||
default:
|
||||
return criteria.RulesetCriteria?.TryParseCustomKeywordCriteria(key, op, value) ?? false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user