Fix for query capital chars in wb ratio condition

This commit is contained in:
Strahinja Val Markovic 2012-06-24 18:13:35 -07:00
parent d18b89bceb
commit ee2bfe8952
2 changed files with 11 additions and 5 deletions

View File

@ -29,11 +29,11 @@ namespace YouCompleteMe
namespace namespace
{ {
template< class T > int LongestCommonSubsequenceLength(const std::string &first,
int LongestCommonSubsequenceLength(const T &first, const T &second) const std::string &second)
{ {
const T &longer = first.size() > second.size() ? first : second; const std::string &longer = first.size() > second.size() ? first : second;
const T &shorter = first.size() > second.size() ? second : first; const std::string &shorter = first.size() > second.size() ? second : first;
int longer_len = longer.size(); int longer_len = longer.size();
int shorter_len = shorter.size(); int shorter_len = shorter.size();
@ -45,7 +45,7 @@ int LongestCommonSubsequenceLength(const T &first, const T &second)
{ {
for (int j = 0; j < shorter_len; ++j ) for (int j = 0; j < shorter_len; ++j )
{ {
if ( longer[ i ] == shorter[ j ] ) if ( toupper( longer[ i ] ) == toupper( shorter[ j ] ) )
current[ j + 1 ] = previous[ j ] + 1; current[ j + 1 ] = previous[ j ] + 1;
else else
current[ j + 1 ] = std::max( current[ j ], previous[ j + 1 ] ); current[ j + 1 ] = std::max( current[ j ], previous[ j + 1 ] );

View File

@ -134,6 +134,12 @@ TEST( CompleterTest, RatioUtilizationTieBreak )
ElementsAre( "acaaCaaFooGxx", ElementsAre( "acaaCaaFooGxx",
"aCaafoog" ) ); "aCaafoog" ) );
EXPECT_THAT( Completer( Candidates(
"acaaCaaFooGxx",
"aCaafoog" ) ).CandidatesForQuery( "caaFoo" ),
ElementsAre( "acaaCaaFooGxx",
"aCaafoog" ) );
EXPECT_THAT( Completer( Candidates( EXPECT_THAT( Completer( Candidates(
"FooBarQux", "FooBarQux",
"FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ), "FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),