Formatting more code with astyle

This commit is contained in:
Strahinja Val Markovic 2013-01-19 20:17:12 -08:00
parent 4308130ab3
commit 1641bc9683
10 changed files with 257 additions and 262 deletions

View File

@ -19,19 +19,16 @@
#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(
@ -52,8 +49,7 @@ TEST( CandidateTest, MatchesQueryBitsetWhenMatch )
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() );

View File

@ -26,11 +26,9 @@ 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" );
@ -47,8 +45,7 @@ TEST( ClangCompleterTest, CandidatesForLocationInFile )
} }
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" );

View File

@ -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 );

View File

@ -24,22 +24,21 @@
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" ),
@ -47,16 +46,16 @@ TEST( IdentifierCompleterTest, NoDuplicatesReturned )
} }
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" ),
@ -65,131 +64,142 @@ TEST( IdentifierCompleterTest, ManyCandidateSimple )
"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(
StringVector(
"CompleterTest", "CompleterTest",
"CompleteMatchForWordBoundaryCharsWins" ) ) "CompleteMatchForWordBoundaryCharsWins" ) )
.CandidatesForQuery( "ct" ), .CandidatesForQuery( "ct" ),
ElementsAre( "CompleterTest", ElementsAre( "CompleterTest",
"CompleteMatchForWordBoundaryCharsWins" ) ); "CompleteMatchForWordBoundaryCharsWins" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBar", "FooBar",
"FooBarRux" ) ).CandidatesForQuery( "fbr" ), "FooBarRux" ) ).CandidatesForQuery( "fbr" ),
ElementsAre( "FooBarRux", ElementsAre( "FooBarRux",
"FooBar" ) ); "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(
StringVector(
"aFooBarQux", "aFooBarQux",
"afbq" ) ).CandidatesForQuery( "fbq" ), "afbq" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "aFooBarQux", ElementsAre( "aFooBarQux",
"afbq" ) ); "afbq" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"acaaCaaFooGxx", "acaaCaaFooGxx",
"aCaafoog" ) ).CandidatesForQuery( "caafoo" ), "aCaafoog" ) ).CandidatesForQuery( "caafoo" ),
ElementsAre( "acaaCaaFooGxx", ElementsAre( "acaaCaaFooGxx",
"aCaafoog" ) ); "aCaafoog" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"acaaCaaFooGxx", "acaaCaaFooGxx",
"aCaafoog" ) ).CandidatesForQuery( "caaFoo" ), "aCaafoog" ) ).CandidatesForQuery( "caaFoo" ),
ElementsAre( "acaaCaaFooGxx", ElementsAre( "acaaCaaFooGxx",
"aCaafoog" ) ); "aCaafoog" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBarQux", "FooBarQux",
"FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ), "FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "FooBarQux", ElementsAre( "FooBarQux",
"FooBarQuxZaa" ) ); "FooBarQuxZaa" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBar", "FooBar",
"FooBarRux" ) ).CandidatesForQuery( "fba" ), "FooBarRux" ) ).CandidatesForQuery( "fba" ),
ElementsAre( "FooBar", ElementsAre( "FooBar",
"FooBarRux" ) ); "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(
StringVector(
"barfooq", "barfooq",
"barquxfoo" ) ).CandidatesForQuery( "foo" ), "barquxfoo" ) ).CandidatesForQuery( "foo" ),
ElementsAre( "barfooq", ElementsAre( "barfooq",
"barquxfoo") ); "barquxfoo" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"xxxxxxabc", "xxxxxxabc",
"xxabcxxxx" ) ).CandidatesForQuery( "abc" ), "xxabcxxxx" ) ).CandidatesForQuery( "abc" ),
ElementsAre( "xxabcxxxx", ElementsAre( "xxabcxxxx",
"xxxxxxabc") ); "xxxxxxabc" ) );
EXPECT_THAT( IdentifierCompleter( StringVector( EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBarQux", "FooBarQux",
"FaBarQux" ) ).CandidatesForQuery( "fbq" ), "FaBarQux" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "FaBarQux", ElementsAre( "FaBarQux",
"FooBarQux" ) ); "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(
StringVector(
"CompleterT", "CompleterT",
"CompleterTest" ) ).CandidatesForQuery( "plet" ), "CompleterTest" ) ).CandidatesForQuery( "plet" ),
ElementsAre( "CompleterT", ElementsAre( "CompleterT",
"CompleterTest" ) ); "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",

View File

@ -22,12 +22,10 @@
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"
@ -76,8 +74,7 @@ TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks )
} }
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]"
), ),

View File

@ -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' ) );

View File

@ -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' ) );

View File

@ -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' ) );

View File

@ -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,24 +27,31 @@ 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 );

View File

@ -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(),