2014-01-13 14:08:43 -05:00
|
|
|
// Copyright (C) 2011, 2012 Google Inc.
|
2012-08-11 22:27:15 -04:00
|
|
|
//
|
|
|
|
// This file is part of YouCompleteMe.
|
|
|
|
//
|
|
|
|
// YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include "ClangCompleter.h"
|
|
|
|
#include "CompletionData.h"
|
2013-05-26 16:28:00 -04:00
|
|
|
#include "../TestUtils.h"
|
|
|
|
|
2012-08-11 22:27:15 -04:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2013-05-26 16:28:00 -04:00
|
|
|
|
|
|
|
namespace YouCompleteMe {
|
2012-08-11 22:27:15 -04:00
|
|
|
|
|
|
|
using ::testing::ElementsAre;
|
|
|
|
using ::testing::WhenSorted;
|
|
|
|
|
2013-01-19 23:17:12 -05:00
|
|
|
TEST( ClangCompleterTest, CandidatesForLocationInFile ) {
|
2012-08-11 22:27:15 -04:00
|
|
|
ClangCompleter completer;
|
|
|
|
std::vector< CompletionData > completions =
|
|
|
|
completer.CandidatesForLocationInFile(
|
2013-05-26 16:28:00 -04:00
|
|
|
PathToTestFile( "basic.cpp" ).string(),
|
2013-01-19 23:17:12 -05:00
|
|
|
11,
|
|
|
|
7,
|
|
|
|
std::vector< UnsavedFile >(),
|
|
|
|
std::vector< std::string >() );
|
2012-08-11 22:27:15 -04:00
|
|
|
|
|
|
|
EXPECT_TRUE( !completions.empty() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-27 17:59:00 -04:00
|
|
|
TEST( ClangCompleterTest, GetDefinitionLocation ) {
|
|
|
|
ClangCompleter completer;
|
|
|
|
std::string filename = PathToTestFile( "basic.cpp" ).string();
|
|
|
|
|
|
|
|
// Clang operates on the reasonable assumption that line and column numbers
|
|
|
|
// are 1-based.
|
|
|
|
Location actual_location =
|
|
|
|
completer.GetDefinitionLocation(
|
|
|
|
filename,
|
|
|
|
9,
|
|
|
|
3,
|
|
|
|
std::vector< UnsavedFile >(),
|
|
|
|
std::vector< std::string >() );
|
|
|
|
|
|
|
|
EXPECT_EQ( Location( filename, 1, 8 ), actual_location );
|
|
|
|
}
|
|
|
|
|
2012-08-11 22:27:15 -04:00
|
|
|
} // namespace YouCompleteMe
|