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 "Result.h"
namespace YouCompleteMe
{
namespace YouCompleteMe {
TEST( CandidateTest, TextValid )
{
TEST( CandidateTest, TextValid ) {
std::string text = "foo";
Candidate candidate( text );
EXPECT_EQ( text, candidate.Text() );
}
TEST( CandidateTest, MatchesQueryBitsetWhenMatch )
{
TEST( CandidateTest, MatchesQueryBitsetWhenMatch ) {
Candidate candidate( "foobaaar" );
EXPECT_TRUE( candidate.MatchesQueryBitset(
@ -52,8 +49,7 @@ TEST( CandidateTest, MatchesQueryBitsetWhenMatch )
LetterBitsetFromString( "" ) ) );
}
TEST( CandidateTest, DoesntMatchQueryBitset )
{
TEST( CandidateTest, DoesntMatchQueryBitset ) {
Candidate candidate( "foobar" );
EXPECT_FALSE( candidate.MatchesQueryBitset(
@ -68,8 +64,7 @@ TEST( CandidateTest, DoesntMatchQueryBitset )
LetterBitsetFromString( "fbrmmm" ) ) );
}
TEST( CandidateTest, QueryMatchResultIsSubsequence )
{
TEST( CandidateTest, QueryMatchResultIsSubsequence ) {
Candidate candidate( "foobaaar" );
EXPECT_TRUE( candidate.QueryMatchResult( "foobaaar" ).IsSubsequence() );
@ -88,8 +83,7 @@ TEST( CandidateTest, QueryMatchResultIsSubsequence )
EXPECT_TRUE( candidate.QueryMatchResult( "" ).IsSubsequence() );
}
TEST( CandidateTest, QueryMatchResultIsntSubsequence )
{
TEST( CandidateTest, QueryMatchResultIsntSubsequence ) {
Candidate candidate( "foobaaar" );
EXPECT_FALSE( candidate.QueryMatchResult( "foobra" ).IsSubsequence() );

View File

@ -26,11 +26,9 @@ namespace fs = boost::filesystem;
using ::testing::ElementsAre;
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 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 test_file = path_to_testdata / fs::path( "basic.cpp" );

View File

@ -27,11 +27,9 @@ namespace fs = boost::filesystem;
using ::testing::ElementsAre;
using ::testing::WhenSorted;
namespace YouCompleteMe
{
namespace YouCompleteMe {
TEST( TranslationUnitTest, ExceptionThrownOnParseFailure )
{
TEST( TranslationUnitTest, ExceptionThrownOnParseFailure ) {
fs::path test_file = fs::temp_directory_path() / fs::unique_path();
std::string junk = "#&9112(^(^#>@(^@!@(&#@a}}}}{nthoeu\n&&^^&^&!#%%@@!aeu";
WriteUtf8File( test_file, junk );

View File

@ -24,22 +24,21 @@
using ::testing::ElementsAre;
using ::testing::WhenSorted;
namespace YouCompleteMe
{
namespace YouCompleteMe {
// This differs from what we expect from the ClangCompleter. That one should
// return results for an empty query.
TEST( IdentifierCompleterTest, EmptyQueryNoResults )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, EmptyQueryNoResults ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar" ) ).CandidatesForQuery( "" ),
ElementsAre() );
}
TEST( IdentifierCompleterTest, NoDuplicatesReturned )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, NoDuplicatesReturned ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar",
"foobar",
"foobar" ) ).CandidatesForQuery( "foo" ),
@ -47,16 +46,16 @@ TEST( IdentifierCompleterTest, NoDuplicatesReturned )
}
TEST( IdentifierCompleterTest, OneCandidate )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, OneCandidate ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar" ) ).CandidatesForQuery( "fbr" ),
ElementsAre( "foobar" ) );
}
TEST( IdentifierCompleterTest, ManyCandidateSimple )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, ManyCandidateSimple ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar",
"foobartest",
"Foobartest" ) ).CandidatesForQuery( "fbr" ),
@ -65,131 +64,142 @@ TEST( IdentifierCompleterTest, ManyCandidateSimple )
"foobartest" ) ) );
}
TEST( IdentifierCompleterTest, FirstCharSameAsQueryWins )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, FirstCharSameAsQueryWins ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar",
"afoobar" ) ).CandidatesForQuery( "fbr" ),
ElementsAre( "foobar",
"afoobar" ) );
}
TEST( IdentifierCompleterTest, CompleteMatchForWordBoundaryCharsWins )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, CompleteMatchForWordBoundaryCharsWins ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBarQux",
"FBaqux" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "FooBarQux",
"FBaqux" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"CompleterTest",
"CompleteMatchForWordBoundaryCharsWins" ) )
.CandidatesForQuery( "ct" ),
ElementsAre( "CompleterTest",
"CompleteMatchForWordBoundaryCharsWins" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBar",
"FooBarRux" ) ).CandidatesForQuery( "fbr" ),
ElementsAre( "FooBarRux",
"FooBar" ) );
}
TEST( IdentifierCompleterTest, RatioUtilizationTieBreak )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, RatioUtilizationTieBreak ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"aGaaFooBarQux",
"aBaafbq" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "aGaaFooBarQux",
"aBaafbq" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"aFooBarQux",
"afbq" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "aFooBarQux",
"afbq" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"acaaCaaFooGxx",
"aCaafoog" ) ).CandidatesForQuery( "caafoo" ),
ElementsAre( "acaaCaaFooGxx",
"aCaafoog" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"acaaCaaFooGxx",
"aCaafoog" ) ).CandidatesForQuery( "caaFoo" ),
ElementsAre( "acaaCaaFooGxx",
"aCaafoog" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBarQux",
"FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "FooBarQux",
"FooBarQuxZaa" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBar",
"FooBarRux" ) ).CandidatesForQuery( "fba" ),
ElementsAre( "FooBar",
"FooBarRux" ) );
}
TEST( IdentifierCompleterTest, QueryPrefixOfCandidateWins )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, QueryPrefixOfCandidateWins ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar",
"fbaroo" ) ).CandidatesForQuery( "foo" ),
ElementsAre( "foobar",
"fbaroo" ) );
}
TEST( IdentifierCompleterTest, LowerMatchCharIndexSumWins )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, LowerMatchCharIndexSumWins ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"ratio_of_word_boundary_chars_in_query_",
"first_char_same_in_query_and_text_" ) )
.CandidatesForQuery( "charinq" ),
ElementsAre( "first_char_same_in_query_and_text_",
"ratio_of_word_boundary_chars_in_query_" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"barfooq",
"barquxfoo" ) ).CandidatesForQuery( "foo" ),
ElementsAre( "barfooq",
"barquxfoo" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"xxxxxxabc",
"xxabcxxxx" ) ).CandidatesForQuery( "abc" ),
ElementsAre( "xxabcxxxx",
"xxxxxxabc" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"FooBarQux",
"FaBarQux" ) ).CandidatesForQuery( "fbq" ),
ElementsAre( "FaBarQux",
"FooBarQux" ) );
}
TEST( IdentifierCompleterTest, ShorterCandidateWins )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, ShorterCandidateWins ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"CompleterT",
"CompleterTest" ) ).CandidatesForQuery( "co" ),
ElementsAre( "CompleterT",
"CompleterTest" ) );
EXPECT_THAT( IdentifierCompleter( StringVector(
EXPECT_THAT( IdentifierCompleter(
StringVector(
"CompleterT",
"CompleterTest" ) ).CandidatesForQuery( "plet" ),
ElementsAre( "CompleterT",
"CompleterTest" ) );
}
TEST( IdentifierCompleterTest, SameLowercaseCandidateWins )
{
EXPECT_THAT( IdentifierCompleter( StringVector(
TEST( IdentifierCompleterTest, SameLowercaseCandidateWins ) {
EXPECT_THAT( IdentifierCompleter(
StringVector(
"foobar",
"Foobar" ) ).CandidatesForQuery( "foo" ),
ElementsAre( "foobar",

View File

@ -22,12 +22,10 @@
using ::testing::ElementsAre;
using ::testing::WhenSorted;
namespace YouCompleteMe
{
namespace YouCompleteMe {
TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks )
{
TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks ) {
EXPECT_STREQ( RemoveIdentifierFreeText(
"foo \n"
"bar //foo \n"
@ -76,8 +74,7 @@ TEST( IdentifierUtilsTest, RemoveIdentifierFreeTextWorks )
}
TEST( IdentifierUtilsTest, ExtractIdentifiersFromTextWorks )
{
TEST( IdentifierUtilsTest, ExtractIdentifiersFromTextWorks ) {
EXPECT_THAT( ExtractIdentifiersFromText(
"foo $_bar \n&BazGoo\n FOO= !!! '-' - _ (x) one-two !moo [qqq]"
),

View File

@ -18,11 +18,9 @@
#include <gtest/gtest.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>( 'z' ), IndexForChar( 'z' ) );

View File

@ -18,11 +18,9 @@
#include <gtest/gtest.h>
#include "LetterNodeListMap.h"
namespace YouCompleteMe
{
namespace YouCompleteMe {
TEST( IsUppercaseTest, Basic )
{
TEST( IsUppercaseTest, Basic ) {
EXPECT_TRUE( IsUppercase( 'A' ) );
EXPECT_TRUE( IsUppercase( 'B' ) );
EXPECT_TRUE( IsUppercase( 'Z' ) );

View File

@ -18,11 +18,9 @@
#include <gtest/gtest.h>
#include "Candidate.h"
namespace YouCompleteMe
{
namespace YouCompleteMe {
TEST( LetterBitsetFromStringTest, Basic )
{
TEST( LetterBitsetFromStringTest, Basic ) {
Bitset expected;
expected.set( IndexForChar( 'a' ) );
expected.set( IndexForChar( 'o' ) );

View File

@ -17,8 +17,7 @@
#include "TestUtils.h"
namespace YouCompleteMe
{
namespace YouCompleteMe {
std::vector< std::string > StringVector( const std::string &a,
const std::string &b,
@ -28,24 +27,31 @@ std::vector< std::string > StringVector( const std::string &a,
const std::string &f,
const std::string &g,
const std::string &h,
const std::string &i )
{
const std::string &i ) {
std::vector< std::string > string_vector;
string_vector.push_back( a );
if ( !b.empty() )
string_vector.push_back( b );
if ( !c.empty() )
string_vector.push_back( c );
if ( !d.empty() )
string_vector.push_back( d );
if ( !e.empty() )
string_vector.push_back( e );
if ( !f.empty() )
string_vector.push_back( f );
if ( !g.empty() )
string_vector.push_back( g );
if ( !h.empty() )
string_vector.push_back( h );
if ( !i.empty() )
string_vector.push_back( i );

View File

@ -21,8 +21,7 @@
#include <vector>
#include <string>
namespace YouCompleteMe
{
namespace YouCompleteMe {
std::vector< std::string > StringVector( const std::string &a,
const std::string &b = std::string(),