mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add unit tests for checking substrings
checking if all substrings contained in compareString
This commit is contained in:
parent
0093838a75
commit
24cc5dbaa0
2 changed files with 23 additions and 1 deletions
|
|
@ -147,7 +147,8 @@ namespace Wox.Infrastructure
|
|||
{
|
||||
Success = true,
|
||||
MatchData = indexList,
|
||||
RawScore = Math.Max(score, pinyinScore)
|
||||
RawScore = Math.Max(score, pinyinScore),
|
||||
AllSubstringsContainedInCompareString = allSubstringsContainedInCompareString
|
||||
};
|
||||
|
||||
return result;
|
||||
|
|
@ -288,6 +289,11 @@ namespace Wox.Infrastructure
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if all query's substrings are contained in the string to compare
|
||||
/// </summary>
|
||||
public bool AllSubstringsContainedInCompareString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Matched data to highlight.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -247,5 +247,21 @@ namespace Wox.Test
|
|||
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
||||
$"Precision Level: {expectedPrecisionString}={expectedPrecisionScore}");
|
||||
}
|
||||
|
||||
[TestCase("sql servman", MicrosoftSqlServerManagementStudio, false)]
|
||||
[TestCase("sql serv man", MicrosoftSqlServerManagementStudio, true)]
|
||||
[TestCase("sql", MicrosoftSqlServerManagementStudio, true)]
|
||||
[TestCase("sqlserv", MicrosoftSqlServerManagementStudio, false)]
|
||||
[TestCase("mssms", MicrosoftSqlServerManagementStudio, false)]
|
||||
[TestCase("chr", "Change settings for text-to-speech and for speech recognition (if installed).", false)]
|
||||
[TestCase("ch r", "Change settings for text-to-speech and for speech recognition (if installed).", true)]
|
||||
public void WhenGivenQueryShouldEvaluateTrueFalseIfCompareStringContainsAllSubstrings(string queryString, string compareString, bool expectedResult)
|
||||
{
|
||||
// When, Given
|
||||
var matchResult = StringMatcher.FuzzySearch(queryString, compareString).AllSubstringsContainedInCompareString;
|
||||
|
||||
// Should
|
||||
Assert.AreEqual(matchResult, expectedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue