mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Add unit tests for checking substrings
checking if all substrings contained in compareString
This commit is contained in:
@@ -147,7 +147,8 @@ namespace Wox.Infrastructure
|
|||||||
{
|
{
|
||||||
Success = true,
|
Success = true,
|
||||||
MatchData = indexList,
|
MatchData = indexList,
|
||||||
RawScore = Math.Max(score, pinyinScore)
|
RawScore = Math.Max(score, pinyinScore),
|
||||||
|
AllSubstringsContainedInCompareString = allSubstringsContainedInCompareString
|
||||||
};
|
};
|
||||||
|
|
||||||
return result;
|
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>
|
/// <summary>
|
||||||
/// Matched data to highlight.
|
/// Matched data to highlight.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -247,5 +247,21 @@ namespace Wox.Test
|
|||||||
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
$"Raw Score: {matchResult.RawScore}{Environment.NewLine}" +
|
||||||
$"Precision Level: {expectedPrecisionString}={expectedPrecisionScore}");
|
$"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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user