Formatting more code with astyle
This commit is contained in:
parent
4308130ab3
commit
1641bc9683
@ -19,41 +19,37 @@
|
|||||||
#include "Candidate.h"
|
#include "Candidate.h"
|
||||||
#include "Result.h"
|
#include "Result.h"
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
TEST( CandidateTest, TextValid )
|
TEST( CandidateTest, TextValid ) {
|
||||||
{
|
|
||||||
std::string text = "foo";
|
std::string text = "foo";
|
||||||
Candidate candidate( text );
|
Candidate candidate( text );
|
||||||
|
|
||||||
EXPECT_EQ( text, candidate.Text() );
|
EXPECT_EQ( text, candidate.Text() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( CandidateTest, MatchesQueryBitsetWhenMatch )
|
TEST( CandidateTest, MatchesQueryBitsetWhenMatch ) {
|
||||||
{
|
|
||||||
Candidate candidate( "foobaaar" );
|
Candidate candidate( "foobaaar" );
|
||||||
|
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "foobaaar" ) ) );
|
LetterBitsetFromString( "foobaaar" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "fobar" ) ) );
|
LetterBitsetFromString( "fobar" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "rabof" ) ) );
|
LetterBitsetFromString( "rabof" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "bfroa" ) ) );
|
LetterBitsetFromString( "bfroa" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "fbr" ) ) );
|
LetterBitsetFromString( "fbr" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "r" ) ) );
|
LetterBitsetFromString( "r" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "bbb" ) ) );
|
LetterBitsetFromString( "bbb" ) ) );
|
||||||
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
EXPECT_TRUE( candidate.MatchesQueryBitset(
|
||||||
LetterBitsetFromString( "" ) ) );
|
LetterBitsetFromString( "" ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( CandidateTest, DoesntMatchQueryBitset )
|
TEST( CandidateTest, DoesntMatchQueryBitset ) {
|
||||||
{
|
|
||||||
Candidate candidate( "foobar" );
|
Candidate candidate( "foobar" );
|
||||||
|
|
||||||
EXPECT_FALSE( candidate.MatchesQueryBitset(
|
EXPECT_FALSE( candidate.MatchesQueryBitset(
|
||||||
@ -68,8 +64,7 @@ TEST( CandidateTest, DoesntMatchQueryBitset )
|
|||||||
LetterBitsetFromString( "fbrmmm" ) ) );
|
LetterBitsetFromString( "fbrmmm" ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( CandidateTest, QueryMatchResultIsSubsequence )
|
TEST( CandidateTest, QueryMatchResultIsSubsequence ) {
|
||||||
{
|
|
||||||
Candidate candidate( "foobaaar" );
|
Candidate candidate( "foobaaar" );
|
||||||
|
|
||||||
EXPECT_TRUE( candidate.QueryMatchResult( "foobaaar" ).IsSubsequence() );
|
EXPECT_TRUE( candidate.QueryMatchResult( "foobaaar" ).IsSubsequence() );
|
||||||
@ -88,8 +83,7 @@ TEST( CandidateTest, QueryMatchResultIsSubsequence )
|
|||||||
EXPECT_TRUE( candidate.QueryMatchResult( "" ).IsSubsequence() );
|
EXPECT_TRUE( candidate.QueryMatchResult( "" ).IsSubsequence() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( CandidateTest, QueryMatchResultIsntSubsequence )
|
TEST( CandidateTest, QueryMatchResultIsntSubsequence ) {
|
||||||
{
|
|
||||||
Candidate candidate( "foobaaar" );
|
Candidate candidate( "foobaaar" );
|
||||||
|
|
||||||
EXPECT_FALSE( candidate.QueryMatchResult( "foobra" ).IsSubsequence() );
|
EXPECT_FALSE( candidate.QueryMatchResult( "foobra" ).IsSubsequence() );
|
||||||
|
@ -26,29 +26,26 @@ namespace fs = boost::filesystem;
|
|||||||
using ::testing::ElementsAre;
|
using ::testing::ElementsAre;
|
||||||
using ::testing::WhenSorted;
|
using ::testing::WhenSorted;
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
TEST( ClangCompleterTest, CandidatesForLocationInFile )
|
TEST( ClangCompleterTest, CandidatesForLocationInFile ) {
|
||||||
{
|
|
||||||
fs::path path_to_testdata = fs::current_path() / fs::path( "testdata" );
|
fs::path path_to_testdata = fs::current_path() / fs::path( "testdata" );
|
||||||
fs::path test_file = path_to_testdata / fs::path( "basic.cpp" );
|
fs::path test_file = path_to_testdata / fs::path( "basic.cpp" );
|
||||||
|
|
||||||
ClangCompleter completer;
|
ClangCompleter completer;
|
||||||
std::vector< CompletionData > completions =
|
std::vector< CompletionData > completions =
|
||||||
completer.CandidatesForLocationInFile(
|
completer.CandidatesForLocationInFile(
|
||||||
test_file.string(),
|
test_file.string(),
|
||||||
11,
|
11,
|
||||||
7,
|
7,
|
||||||
std::vector< UnsavedFile >(),
|
std::vector< UnsavedFile >(),
|
||||||
std::vector< std::string >() );
|
std::vector< std::string >() );
|
||||||
|
|
||||||
EXPECT_TRUE( !completions.empty() );
|
EXPECT_TRUE( !completions.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST( ClangCompleterTest, CandidatesForQueryAndLocationInFileAsync )
|
TEST( ClangCompleterTest, CandidatesForQueryAndLocationInFileAsync ) {
|
||||||
{
|
|
||||||
fs::path path_to_testdata = fs::current_path() / fs::path( "testdata" );
|
fs::path path_to_testdata = fs::current_path() / fs::path( "testdata" );
|
||||||
fs::path test_file = path_to_testdata / fs::path( "basic.cpp" );
|
fs::path test_file = path_to_testdata / fs::path( "basic.cpp" );
|
||||||
|
|
||||||
@ -57,12 +54,12 @@ TEST( ClangCompleterTest, CandidatesForQueryAndLocationInFileAsync )
|
|||||||
|
|
||||||
Future< AsyncCompletions > completions_future =
|
Future< AsyncCompletions > completions_future =
|
||||||
completer.CandidatesForQueryAndLocationInFileAsync(
|
completer.CandidatesForQueryAndLocationInFileAsync(
|
||||||
"",
|
"",
|
||||||
test_file.string(),
|
test_file.string(),
|
||||||
11,
|
11,
|
||||||
7,
|
7,
|
||||||
std::vector< UnsavedFile >(),
|
std::vector< UnsavedFile >(),
|
||||||
std::vector< std::string >() );
|
std::vector< std::string >() );
|
||||||
|
|
||||||
completions_future.Wait();
|
completions_future.Wait();
|
||||||
|
|
||||||
|
@ -27,11 +27,9 @@ namespace fs = boost::filesystem;
|
|||||||
using ::testing::ElementsAre;
|
using ::testing::ElementsAre;
|
||||||
using ::testing::WhenSorted;
|
using ::testing::WhenSorted;
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
TEST( TranslationUnitTest, ExceptionThrownOnParseFailure )
|
TEST( TranslationUnitTest, ExceptionThrownOnParseFailure ) {
|
||||||
{
|
|
||||||
fs::path test_file = fs::temp_directory_path() / fs::unique_path();
|
fs::path test_file = fs::temp_directory_path() / fs::unique_path();
|
||||||
std::string junk = "#&9112(^(^#>@(^@!@(&#@a}}}}{nthoeu\n&&^^&^&!#%%@@!aeu";
|
std::string junk = "#&9112(^(^#>@(^@!@(&#@a}}}}{nthoeu\n&&^^&^&!#%%@@!aeu";
|
||||||
WriteUtf8File( test_file, junk );
|
WriteUtf8File( test_file, junk );
|
||||||
|
@ -24,176 +24,186 @@
|
|||||||
using ::testing::ElementsAre;
|
using ::testing::ElementsAre;
|
||||||
using ::testing::WhenSorted;
|
using ::testing::WhenSorted;
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// This differs from what we expect from the ClangCompleter. That one should
|
// This differs from what we expect from the ClangCompleter. That one should
|
||||||
// return results for an empty query.
|
// return results for an empty query.
|
||||||
TEST( IdentifierCompleterTest, EmptyQueryNoResults )
|
TEST( IdentifierCompleterTest, EmptyQueryNoResults ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar" ) ).CandidatesForQuery( "" ),
|
"foobar" ) ).CandidatesForQuery( "" ),
|
||||||
ElementsAre() );
|
ElementsAre() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, NoDuplicatesReturned )
|
TEST( IdentifierCompleterTest, NoDuplicatesReturned ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar",
|
"foobar",
|
||||||
"foobar",
|
"foobar",
|
||||||
"foobar" ) ).CandidatesForQuery( "foo" ),
|
"foobar" ) ).CandidatesForQuery( "foo" ),
|
||||||
ElementsAre( "foobar" ) );
|
ElementsAre( "foobar" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, OneCandidate )
|
TEST( IdentifierCompleterTest, OneCandidate ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar" ) ).CandidatesForQuery( "fbr" ),
|
"foobar" ) ).CandidatesForQuery( "fbr" ),
|
||||||
ElementsAre( "foobar" ) );
|
ElementsAre( "foobar" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, ManyCandidateSimple )
|
TEST( IdentifierCompleterTest, ManyCandidateSimple ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar",
|
"foobar",
|
||||||
"foobartest",
|
"foobartest",
|
||||||
"Foobartest" ) ).CandidatesForQuery( "fbr" ),
|
"Foobartest" ) ).CandidatesForQuery( "fbr" ),
|
||||||
WhenSorted( ElementsAre( "Foobartest",
|
WhenSorted( ElementsAre( "Foobartest",
|
||||||
"foobar",
|
"foobar",
|
||||||
"foobartest" ) ) );
|
"foobartest" ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, FirstCharSameAsQueryWins )
|
TEST( IdentifierCompleterTest, FirstCharSameAsQueryWins ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar",
|
"foobar",
|
||||||
"afoobar" ) ).CandidatesForQuery( "fbr" ),
|
"afoobar" ) ).CandidatesForQuery( "fbr" ),
|
||||||
ElementsAre( "foobar",
|
ElementsAre( "foobar",
|
||||||
"afoobar" ) );
|
"afoobar" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, CompleteMatchForWordBoundaryCharsWins )
|
TEST( IdentifierCompleterTest, CompleteMatchForWordBoundaryCharsWins ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"FooBarQux",
|
"FooBarQux",
|
||||||
"FBaqux" ) ).CandidatesForQuery( "fbq" ),
|
"FBaqux" ) ).CandidatesForQuery( "fbq" ),
|
||||||
ElementsAre( "FooBarQux",
|
ElementsAre( "FooBarQux",
|
||||||
"FBaqux" ) );
|
"FBaqux" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"CompleterTest",
|
StringVector(
|
||||||
"CompleteMatchForWordBoundaryCharsWins" ) )
|
"CompleterTest",
|
||||||
.CandidatesForQuery( "ct" ),
|
"CompleteMatchForWordBoundaryCharsWins" ) )
|
||||||
ElementsAre( "CompleterTest",
|
.CandidatesForQuery( "ct" ),
|
||||||
"CompleteMatchForWordBoundaryCharsWins" ) );
|
ElementsAre( "CompleterTest",
|
||||||
|
"CompleteMatchForWordBoundaryCharsWins" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"FooBar",
|
StringVector(
|
||||||
"FooBarRux" ) ).CandidatesForQuery( "fbr" ),
|
"FooBar",
|
||||||
ElementsAre( "FooBarRux",
|
"FooBarRux" ) ).CandidatesForQuery( "fbr" ),
|
||||||
"FooBar" ) );
|
ElementsAre( "FooBarRux",
|
||||||
|
"FooBar" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, RatioUtilizationTieBreak )
|
TEST( IdentifierCompleterTest, RatioUtilizationTieBreak ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"aGaaFooBarQux",
|
"aGaaFooBarQux",
|
||||||
"aBaafbq" ) ).CandidatesForQuery( "fbq" ),
|
"aBaafbq" ) ).CandidatesForQuery( "fbq" ),
|
||||||
ElementsAre( "aGaaFooBarQux",
|
ElementsAre( "aGaaFooBarQux",
|
||||||
"aBaafbq" ) );
|
"aBaafbq" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"aFooBarQux",
|
StringVector(
|
||||||
"afbq" ) ).CandidatesForQuery( "fbq" ),
|
"aFooBarQux",
|
||||||
ElementsAre( "aFooBarQux",
|
"afbq" ) ).CandidatesForQuery( "fbq" ),
|
||||||
"afbq" ) );
|
ElementsAre( "aFooBarQux",
|
||||||
|
"afbq" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"acaaCaaFooGxx",
|
StringVector(
|
||||||
"aCaafoog" ) ).CandidatesForQuery( "caafoo" ),
|
"acaaCaaFooGxx",
|
||||||
ElementsAre( "acaaCaaFooGxx",
|
"aCaafoog" ) ).CandidatesForQuery( "caafoo" ),
|
||||||
"aCaafoog" ) );
|
ElementsAre( "acaaCaaFooGxx",
|
||||||
|
"aCaafoog" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"acaaCaaFooGxx",
|
StringVector(
|
||||||
"aCaafoog" ) ).CandidatesForQuery( "caaFoo" ),
|
"acaaCaaFooGxx",
|
||||||
ElementsAre( "acaaCaaFooGxx",
|
"aCaafoog" ) ).CandidatesForQuery( "caaFoo" ),
|
||||||
"aCaafoog" ) );
|
ElementsAre( "acaaCaaFooGxx",
|
||||||
|
"aCaafoog" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"FooBarQux",
|
StringVector(
|
||||||
"FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),
|
"FooBarQux",
|
||||||
ElementsAre( "FooBarQux",
|
"FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),
|
||||||
"FooBarQuxZaa" ) );
|
ElementsAre( "FooBarQux",
|
||||||
|
"FooBarQuxZaa" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"FooBar",
|
StringVector(
|
||||||
"FooBarRux" ) ).CandidatesForQuery( "fba" ),
|
"FooBar",
|
||||||
ElementsAre( "FooBar",
|
"FooBarRux" ) ).CandidatesForQuery( "fba" ),
|
||||||
"FooBarRux" ) );
|
ElementsAre( "FooBar",
|
||||||
|
"FooBarRux" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, QueryPrefixOfCandidateWins )
|
TEST( IdentifierCompleterTest, QueryPrefixOfCandidateWins ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar",
|
"foobar",
|
||||||
"fbaroo" ) ).CandidatesForQuery( "foo" ),
|
"fbaroo" ) ).CandidatesForQuery( "foo" ),
|
||||||
ElementsAre( "foobar",
|
ElementsAre( "foobar",
|
||||||
"fbaroo" ) );
|
"fbaroo" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, LowerMatchCharIndexSumWins )
|
TEST( IdentifierCompleterTest, LowerMatchCharIndexSumWins ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"ratio_of_word_boundary_chars_in_query_",
|
"ratio_of_word_boundary_chars_in_query_",
|
||||||
"first_char_same_in_query_and_text_") )
|
"first_char_same_in_query_and_text_" ) )
|
||||||
.CandidatesForQuery( "charinq" ),
|
.CandidatesForQuery( "charinq" ),
|
||||||
ElementsAre( "first_char_same_in_query_and_text_",
|
ElementsAre( "first_char_same_in_query_and_text_",
|
||||||
"ratio_of_word_boundary_chars_in_query_") );
|
"ratio_of_word_boundary_chars_in_query_" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"barfooq",
|
StringVector(
|
||||||
"barquxfoo" ) ).CandidatesForQuery( "foo" ),
|
"barfooq",
|
||||||
ElementsAre( "barfooq",
|
"barquxfoo" ) ).CandidatesForQuery( "foo" ),
|
||||||
"barquxfoo") );
|
ElementsAre( "barfooq",
|
||||||
|
"barquxfoo" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"xxxxxxabc",
|
StringVector(
|
||||||
"xxabcxxxx" ) ).CandidatesForQuery( "abc" ),
|
"xxxxxxabc",
|
||||||
ElementsAre( "xxabcxxxx",
|
"xxabcxxxx" ) ).CandidatesForQuery( "abc" ),
|
||||||
"xxxxxxabc") );
|
ElementsAre( "xxabcxxxx",
|
||||||
|
"xxxxxxabc" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"FooBarQux",
|
StringVector(
|
||||||
"FaBarQux" ) ).CandidatesForQuery( "fbq" ),
|
"FooBarQux",
|
||||||
ElementsAre( "FaBarQux",
|
"FaBarQux" ) ).CandidatesForQuery( "fbq" ),
|
||||||
"FooBarQux" ) );
|
ElementsAre( "FaBarQux",
|
||||||
|
"FooBarQux" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, ShorterCandidateWins )
|
TEST( IdentifierCompleterTest, ShorterCandidateWins ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"CompleterT",
|
"CompleterT",
|
||||||
"CompleterTest" ) ).CandidatesForQuery( "co" ),
|
"CompleterTest" ) ).CandidatesForQuery( "co" ),
|
||||||
ElementsAre( "CompleterT",
|
ElementsAre( "CompleterT",
|
||||||
"CompleterTest" ) );
|
"CompleterTest" ) );
|
||||||
|
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
"CompleterT",
|
StringVector(
|
||||||
"CompleterTest" ) ).CandidatesForQuery( "plet" ),
|
"CompleterT",
|
||||||
ElementsAre( "CompleterT",
|
"CompleterTest" ) ).CandidatesForQuery( "plet" ),
|
||||||
"CompleterTest" ) );
|
ElementsAre( "CompleterT",
|
||||||
|
"CompleterTest" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST( IdentifierCompleterTest, SameLowercaseCandidateWins )
|
TEST( IdentifierCompleterTest, SameLowercaseCandidateWins ) {
|
||||||
{
|
EXPECT_THAT( IdentifierCompleter(
|
||||||
EXPECT_THAT( IdentifierCompleter( StringVector(
|
StringVector(
|
||||||
"foobar",
|
"foobar",
|
||||||
"Foobar" ) ).CandidatesForQuery( "foo" ),
|
"Foobar" ) ).CandidatesForQuery( "foo" ),
|
||||||
ElementsAre( "foobar",
|
ElementsAre( "foobar",
|
||||||
"Foobar" ) );
|
"Foobar" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: tests for filepath and filetype candidate storing
|
// TODO: tests for filepath and filetype candidate storing
|
||||||
|
@ -22,75 +22,72 @@
|
|||||||
using ::testing::ElementsAre;
|
using ::testing::ElementsAre;
|
||||||
using ::testing::WhenSorted;
|
using ::testing::WhenSorted;
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks )
|
TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks ) {
|
||||||
{
|
EXPECT_STREQ( RemoveIdentifierFreeText(
|
||||||
EXPECT_STREQ( RemoveIdentifierFreeText(
|
"foo \n"
|
||||||
"foo \n"
|
"bar //foo \n"
|
||||||
"bar //foo \n"
|
"qux"
|
||||||
"qux"
|
).c_str(),
|
||||||
).c_str(),
|
"foo \n"
|
||||||
"foo \n"
|
"bar \n"
|
||||||
"bar \n"
|
"qux" );
|
||||||
"qux" );
|
|
||||||
|
|
||||||
EXPECT_STREQ( RemoveIdentifierFreeText(
|
EXPECT_STREQ( RemoveIdentifierFreeText(
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar #foo \n"
|
"bar #foo \n"
|
||||||
"qux"
|
"qux"
|
||||||
).c_str(),
|
).c_str(),
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar \n"
|
"bar \n"
|
||||||
"qux" );
|
"qux" );
|
||||||
|
|
||||||
EXPECT_STREQ( RemoveIdentifierFreeText(
|
EXPECT_STREQ( RemoveIdentifierFreeText(
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar /* foo \n"
|
"bar /* foo \n"
|
||||||
" foo2 */\n"
|
" foo2 */\n"
|
||||||
"qux"
|
"qux"
|
||||||
).c_str(),
|
).c_str(),
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar \n"
|
"bar \n"
|
||||||
"qux" );
|
"qux" );
|
||||||
|
|
||||||
EXPECT_STREQ( RemoveIdentifierFreeText(
|
EXPECT_STREQ( RemoveIdentifierFreeText(
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar 'foo'\n"
|
"bar 'foo'\n"
|
||||||
"qux"
|
"qux"
|
||||||
).c_str(),
|
).c_str(),
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar \n"
|
"bar \n"
|
||||||
"qux" );
|
"qux" );
|
||||||
|
|
||||||
EXPECT_STREQ( RemoveIdentifierFreeText(
|
EXPECT_STREQ( RemoveIdentifierFreeText(
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar \"foo\"\n"
|
"bar \"foo\"\n"
|
||||||
"qux"
|
"qux"
|
||||||
).c_str(),
|
).c_str(),
|
||||||
"foo \n"
|
"foo \n"
|
||||||
"bar \n"
|
"bar \n"
|
||||||
"qux" );
|
"qux" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST( IdentifierUtilsTest, ExtractIdentifiersFromTextWorks )
|
TEST( IdentifierUtilsTest, ExtractIdentifiersFromTextWorks ) {
|
||||||
{
|
EXPECT_THAT( ExtractIdentifiersFromText(
|
||||||
EXPECT_THAT( ExtractIdentifiersFromText(
|
"foo $_bar \n&BazGoo\n FOO= !!! '-' - _ (x) one-two !moo [qqq]"
|
||||||
"foo $_bar \n&BazGoo\n FOO= !!! '-' - _ (x) one-two !moo [qqq]"
|
),
|
||||||
),
|
ElementsAre( "foo",
|
||||||
ElementsAre( "foo",
|
"_bar",
|
||||||
"_bar",
|
"BazGoo",
|
||||||
"BazGoo",
|
"FOO",
|
||||||
"FOO",
|
"_",
|
||||||
"_",
|
"x",
|
||||||
"x",
|
"one",
|
||||||
"one",
|
"two",
|
||||||
"two",
|
"moo",
|
||||||
"moo",
|
"qqq" ) );
|
||||||
"qqq" ) );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,9 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "LetterNodeListMap.h"
|
#include "LetterNodeListMap.h"
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
TEST( IndexForCharTest, Basic )
|
TEST( IndexForCharTest, Basic ) {
|
||||||
{
|
|
||||||
EXPECT_EQ( static_cast<int>( 'a' ), IndexForChar( 'a' ) );
|
EXPECT_EQ( static_cast<int>( 'a' ), IndexForChar( 'a' ) );
|
||||||
EXPECT_EQ( static_cast<int>( 'a' ), IndexForChar( 'A' ) );
|
EXPECT_EQ( static_cast<int>( 'a' ), IndexForChar( 'A' ) );
|
||||||
EXPECT_EQ( static_cast<int>( 'z' ), IndexForChar( 'z' ) );
|
EXPECT_EQ( static_cast<int>( 'z' ), IndexForChar( 'z' ) );
|
||||||
|
@ -18,11 +18,9 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "LetterNodeListMap.h"
|
#include "LetterNodeListMap.h"
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
TEST( IsUppercaseTest, Basic )
|
TEST( IsUppercaseTest, Basic ) {
|
||||||
{
|
|
||||||
EXPECT_TRUE( IsUppercase( 'A' ) );
|
EXPECT_TRUE( IsUppercase( 'A' ) );
|
||||||
EXPECT_TRUE( IsUppercase( 'B' ) );
|
EXPECT_TRUE( IsUppercase( 'B' ) );
|
||||||
EXPECT_TRUE( IsUppercase( 'Z' ) );
|
EXPECT_TRUE( IsUppercase( 'Z' ) );
|
||||||
|
@ -18,11 +18,9 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "Candidate.h"
|
#include "Candidate.h"
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
TEST( LetterBitsetFromStringTest, Basic )
|
TEST( LetterBitsetFromStringTest, Basic ) {
|
||||||
{
|
|
||||||
Bitset expected;
|
Bitset expected;
|
||||||
expected.set( IndexForChar( 'a' ) );
|
expected.set( IndexForChar( 'a' ) );
|
||||||
expected.set( IndexForChar( 'o' ) );
|
expected.set( IndexForChar( 'o' ) );
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
|
|
||||||
#include "TestUtils.h"
|
#include "TestUtils.h"
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
std::vector< std::string > StringVector( const std::string &a,
|
std::vector< std::string > StringVector( const std::string &a,
|
||||||
const std::string &b,
|
const std::string &b,
|
||||||
@ -28,25 +27,32 @@ std::vector< std::string > StringVector( const std::string &a,
|
|||||||
const std::string &f,
|
const std::string &f,
|
||||||
const std::string &g,
|
const std::string &g,
|
||||||
const std::string &h,
|
const std::string &h,
|
||||||
const std::string &i )
|
const std::string &i ) {
|
||||||
{
|
|
||||||
std::vector< std::string > string_vector;
|
std::vector< std::string > string_vector;
|
||||||
string_vector.push_back( a );
|
string_vector.push_back( a );
|
||||||
if ( !b.empty() )
|
|
||||||
|
if ( !b.empty() )
|
||||||
string_vector.push_back( b );
|
string_vector.push_back( b );
|
||||||
if ( !c.empty() )
|
|
||||||
|
if ( !c.empty() )
|
||||||
string_vector.push_back( c );
|
string_vector.push_back( c );
|
||||||
if ( !d.empty() )
|
|
||||||
|
if ( !d.empty() )
|
||||||
string_vector.push_back( d );
|
string_vector.push_back( d );
|
||||||
if ( !e.empty() )
|
|
||||||
|
if ( !e.empty() )
|
||||||
string_vector.push_back( e );
|
string_vector.push_back( e );
|
||||||
if ( !f.empty() )
|
|
||||||
|
if ( !f.empty() )
|
||||||
string_vector.push_back( f );
|
string_vector.push_back( f );
|
||||||
if ( !g.empty() )
|
|
||||||
|
if ( !g.empty() )
|
||||||
string_vector.push_back( g );
|
string_vector.push_back( g );
|
||||||
if ( !h.empty() )
|
|
||||||
|
if ( !h.empty() )
|
||||||
string_vector.push_back( h );
|
string_vector.push_back( h );
|
||||||
if ( !i.empty() )
|
|
||||||
|
if ( !i.empty() )
|
||||||
string_vector.push_back( i );
|
string_vector.push_back( i );
|
||||||
|
|
||||||
return string_vector;
|
return string_vector;
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace YouCompleteMe
|
namespace YouCompleteMe {
|
||||||
{
|
|
||||||
|
|
||||||
std::vector< std::string > StringVector( const std::string &a,
|
std::vector< std::string > StringVector( const std::string &a,
|
||||||
const std::string &b = std::string(),
|
const std::string &b = std::string(),
|
||||||
|
Loading…
Reference in New Issue
Block a user