mirror of https://github.com/ppy/osu
Add test coverage of new matching mode
This commit is contained in:
parent
c423f77d53
commit
19ec6d5455
|
@ -169,6 +169,8 @@ public void TestCriteriaMatchingTerms(string terms, bool filtered)
|
|||
[TestCase("\"tags to\"", true)]
|
||||
[TestCase("\"version\"", false)]
|
||||
[TestCase("\"an auteur\"", true)]
|
||||
[TestCase("\"Artist\"!", true)]
|
||||
[TestCase("\"The Artist\"!", false)]
|
||||
[TestCase("\"\\\"", true)] // nasty case, covers properly escaping user input in underlying regex.
|
||||
public void TestCriteriaMatchingExactTerms(string terms, bool filtered)
|
||||
{
|
||||
|
@ -213,6 +215,8 @@ public void TestCriteriaMatchingCreator(string creatorName, bool filtered)
|
|||
[TestCase("the artist AND then something else", true)]
|
||||
[TestCase("unicode too", false)]
|
||||
[TestCase("unknown", true)]
|
||||
[TestCase("\"Artist\"!", true)]
|
||||
[TestCase("\"The Artist\"!", false)]
|
||||
public void TestCriteriaMatchingArtist(string artistName, bool filtered)
|
||||
{
|
||||
var exampleBeatmapInfo = getExampleBeatmap();
|
||||
|
|
|
@ -26,26 +26,26 @@ public void TestApplyQueriesBareWords()
|
|||
[Test]
|
||||
public void TestApplyQueriesBareWordsWithExactMatch()
|
||||
{
|
||||
const string query = "looking for \"a beatmap\" like \"this\"";
|
||||
const string query = "looking for \"a beatmap\"! like \"this\"";
|
||||
var filterCriteria = new FilterCriteria();
|
||||
FilterQueryParser.ApplyQueries(filterCriteria, query);
|
||||
Assert.AreEqual("looking for \"a beatmap\" like \"this\"", filterCriteria.SearchText);
|
||||
Assert.AreEqual("looking for \"a beatmap\"! like \"this\"", filterCriteria.SearchText);
|
||||
Assert.AreEqual(5, filterCriteria.SearchTerms.Length);
|
||||
|
||||
Assert.That(filterCriteria.SearchTerms[0].SearchTerm, Is.EqualTo("a beatmap"));
|
||||
Assert.That(filterCriteria.SearchTerms[0].Exact, Is.True);
|
||||
Assert.That(filterCriteria.SearchTerms[0].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.FullPhrase));
|
||||
|
||||
Assert.That(filterCriteria.SearchTerms[1].SearchTerm, Is.EqualTo("this"));
|
||||
Assert.That(filterCriteria.SearchTerms[1].Exact, Is.True);
|
||||
Assert.That(filterCriteria.SearchTerms[1].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase));
|
||||
|
||||
Assert.That(filterCriteria.SearchTerms[2].SearchTerm, Is.EqualTo("looking"));
|
||||
Assert.That(filterCriteria.SearchTerms[2].Exact, Is.False);
|
||||
Assert.That(filterCriteria.SearchTerms[2].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.None));
|
||||
|
||||
Assert.That(filterCriteria.SearchTerms[3].SearchTerm, Is.EqualTo("for"));
|
||||
Assert.That(filterCriteria.SearchTerms[3].Exact, Is.False);
|
||||
Assert.That(filterCriteria.SearchTerms[3].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.None));
|
||||
|
||||
Assert.That(filterCriteria.SearchTerms[4].SearchTerm, Is.EqualTo("like"));
|
||||
Assert.That(filterCriteria.SearchTerms[4].Exact, Is.False);
|
||||
Assert.That(filterCriteria.SearchTerms[4].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.None));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -260,7 +260,7 @@ public void TestApplyArtistQueries()
|
|||
Assert.AreEqual("find me songs by please", filterCriteria.SearchText.Trim());
|
||||
Assert.AreEqual(5, filterCriteria.SearchTerms.Length);
|
||||
Assert.AreEqual("singer", filterCriteria.Artist.SearchTerm);
|
||||
Assert.That(filterCriteria.Artist.Exact, Is.False);
|
||||
Assert.That(filterCriteria.Artist.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.None));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -272,7 +272,19 @@ public void TestApplyArtistQueriesWithSpaces()
|
|||
Assert.AreEqual("really like yes", filterCriteria.SearchText.Trim());
|
||||
Assert.AreEqual(3, filterCriteria.SearchTerms.Length);
|
||||
Assert.AreEqual("name with space", filterCriteria.Artist.SearchTerm);
|
||||
Assert.That(filterCriteria.Artist.Exact, Is.True);
|
||||
Assert.That(filterCriteria.Artist.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestApplyArtistQueriesWithSpacesFullPhrase()
|
||||
{
|
||||
const string query = "artist=\"The Only One\"!";
|
||||
var filterCriteria = new FilterCriteria();
|
||||
FilterQueryParser.ApplyQueries(filterCriteria, query);
|
||||
Assert.That(filterCriteria.SearchText.Trim(), Is.Empty);
|
||||
Assert.AreEqual(0, filterCriteria.SearchTerms.Length);
|
||||
Assert.AreEqual("The Only One", filterCriteria.Artist.SearchTerm);
|
||||
Assert.That(filterCriteria.Artist.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.FullPhrase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Loading…
Reference in New Issue