diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 1868eee6e1..a5162c2813 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -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 } } + /// + /// Indicates if all query's substrings are contained in the string to compare + /// + public bool AllSubstringsContainedInCompareString { get; set; } + /// /// Matched data to highlight. /// diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 7eb16c8a0c..660a8ff96d 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -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); + } } } \ No newline at end of file