| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Copyright (C) 2017 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and The Qt Company. For licensing terms | 
					
						
							|  |  |  | ** and conditions see https://www.qt.io/terms-conditions. For further
 | 
					
						
							|  |  |  | ** information use the contact form at https://www.qt.io/contact-us.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** GNU General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU | 
					
						
							|  |  |  | ** General Public License version 3 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
					
						
							|  |  |  | ** included in the packaging of this file. Please review the following | 
					
						
							|  |  |  | ** information to ensure the GNU General Public License requirements will | 
					
						
							|  |  |  | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "googletest.h"
 | 
					
						
							|  |  |  | #include "testenvironment.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 12:28:01 +02:00
										 |  |  | #include <clangsupport_global.h>
 | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | #include <clangfollowsymboljob.h>
 | 
					
						
							|  |  |  | #include <clangdocument.h>
 | 
					
						
							|  |  |  | #include <clangdocuments.h>
 | 
					
						
							|  |  |  | #include <clangtranslationunit.h>
 | 
					
						
							|  |  |  | #include <fixitcontainer.h>
 | 
					
						
							| 
									
										
										
										
											2018-06-01 10:46:20 +02:00
										 |  |  | #include <followsymbolmessage.h>
 | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | #include <sourcelocationcontainer.h>
 | 
					
						
							|  |  |  | #include <sourcerangecontainer.h>
 | 
					
						
							|  |  |  | #include <unsavedfiles.h>
 | 
					
						
							|  |  |  | #include <commandlinearguments.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <utils/qtcassert.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <clang-c/Index.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using ::testing::Contains; | 
					
						
							|  |  |  | using ::testing::Not; | 
					
						
							|  |  |  | using ::testing::ContainerEq; | 
					
						
							|  |  |  | using ::testing::Eq; | 
					
						
							|  |  |  | using ::testing::PrintToString; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using ::ClangBackEnd::SourceLocationContainer; | 
					
						
							|  |  |  | using ::ClangBackEnd::Document; | 
					
						
							|  |  |  | using ::ClangBackEnd::UnsavedFiles; | 
					
						
							|  |  |  | using ::ClangBackEnd::ReferencesResult; | 
					
						
							|  |  |  | using ::ClangBackEnd::SourceRangeContainer; | 
					
						
							| 
									
										
										
										
											2018-06-01 10:46:20 +02:00
										 |  |  | using ::ClangBackEnd::FollowSymbolResult; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace { | 
					
						
							|  |  |  | const Utf8String sourceFilePath = Utf8StringLiteral(TESTDATA_DIR"/followsymbol_main.cpp"); | 
					
						
							|  |  |  | const Utf8String headerFilePath = Utf8StringLiteral(TESTDATA_DIR"/followsymbol_header.h"); | 
					
						
							|  |  |  | const Utf8String cursorPath = Utf8StringLiteral(TESTDATA_DIR"/cursor.cpp"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MATCHER_P3(MatchesHeaderSourceRange, line, column, length, | 
					
						
							|  |  |  |            std::string(negation ? "isn't " : "is ") | 
					
						
							|  |  |  |            + PrintToString(SourceRangeContainer { | 
					
						
							|  |  |  |                                SourceLocationContainer(headerFilePath, line, column), | 
					
						
							|  |  |  |                                SourceLocationContainer(headerFilePath, line, column + length) | 
					
						
							|  |  |  |                            }) | 
					
						
							|  |  |  |            ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const SourceRangeContainer expected = { | 
					
						
							|  |  |  |         SourceLocationContainer(headerFilePath, line, column), | 
					
						
							|  |  |  |         SourceLocationContainer(headerFilePath, line, column + length) | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-08 09:33:35 +02:00
										 |  |  |     return arg == expected; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MATCHER_P3(MatchesSourceRange, line, column, length, | 
					
						
							|  |  |  |            std::string(negation ? "isn't " : "is ") | 
					
						
							|  |  |  |            + PrintToString(SourceRangeContainer { | 
					
						
							|  |  |  |                                SourceLocationContainer(sourceFilePath, line, column), | 
					
						
							|  |  |  |                                SourceLocationContainer(sourceFilePath, line, column + length) | 
					
						
							|  |  |  |                            }) | 
					
						
							|  |  |  |            ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const SourceRangeContainer expected = { | 
					
						
							|  |  |  |         SourceLocationContainer(sourceFilePath, line, column), | 
					
						
							|  |  |  |         SourceLocationContainer(sourceFilePath, line, column + length) | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-08 09:33:35 +02:00
										 |  |  |     return arg == expected; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MATCHER_P4(MatchesFileSourceRange, filename, line, column, length, | 
					
						
							|  |  |  |            std::string(negation ? "isn't " : "is ") | 
					
						
							|  |  |  |            + PrintToString(SourceRangeContainer { | 
					
						
							|  |  |  |                                SourceLocationContainer(filename, line, column), | 
					
						
							|  |  |  |                                SourceLocationContainer(filename, line, column + length) | 
					
						
							|  |  |  |                            }) | 
					
						
							|  |  |  |            ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const SourceRangeContainer expected = { | 
					
						
							|  |  |  |         SourceLocationContainer(filename, line, column), | 
					
						
							|  |  |  |         SourceLocationContainer(filename, line, column + length) | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-08 09:33:35 +02:00
										 |  |  |     return arg == expected; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Data { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-11-29 15:49:45 +01:00
										 |  |  |     ClangBackEnd::UnsavedFiles unsavedFiles; | 
					
						
							| 
									
										
										
										
											2018-09-25 09:41:32 +02:00
										 |  |  |     ClangBackEnd::Documents documents{unsavedFiles}; | 
					
						
							|  |  |  |     Utf8StringVector compilationArguments{ | 
					
						
							|  |  |  |         TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})}; | 
					
						
							| 
									
										
										
										
											2018-10-19 10:20:27 +02:00
										 |  |  |     Document document = {sourceFilePath, compilationArguments, {}, documents}; | 
					
						
							|  |  |  |     Document headerDocument = {headerFilePath, compilationArguments, {}, documents}; | 
					
						
							| 
									
										
										
										
											2017-11-29 15:49:45 +01:00
										 |  |  |     QVector<Utf8String> deps{sourceFilePath, cursorPath}; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FollowSymbol : public ::testing::Test | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2018-06-01 10:46:20 +02:00
										 |  |  |     FollowSymbolResult followSymbol(uint line, uint column) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  |         return document.translationUnit().followSymbol(line, column); | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-01 10:46:20 +02:00
										 |  |  |     FollowSymbolResult followHeaderSymbol(uint line, uint column) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  |         return headerDocument.translationUnit().followSymbol(line, column); | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static void SetUpTestCase(); | 
					
						
							|  |  |  |     static void TearDownTestCase(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2017-11-29 15:49:45 +01:00
										 |  |  |     static std::unique_ptr<const Data> data; | 
					
						
							|  |  |  |     const Document &document{data->document}; | 
					
						
							|  |  |  |     const Document &headerDocument{data->headerDocument}; | 
					
						
							|  |  |  |     const QVector<Utf8String> &deps{data->deps}; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | // NOTE: some tests are disabled because clang code model does not need to follow symbols
 | 
					
						
							|  |  |  | // to other translation units. When there's infrastructure to test database based follow symbol
 | 
					
						
							|  |  |  | // they should be moved there.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | TEST_F(FollowSymbol, CursorOnNamespace) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(27, 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesHeaderSourceRange(28, 11, 6)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnClassReference) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto classDefinition = followSymbol(27, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(classDefinition, MatchesHeaderSourceRange(34, 7, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnClassForwardDeclarationFollowToHeader) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto classDefinition = followHeaderSymbol(32, 7); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(classDefinition, MatchesHeaderSourceRange(34, 7, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnClassForwardDeclarationFollowToCpp) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto classDefinition = followHeaderSymbol(48, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(classDefinition, MatchesSourceRange(54, 7, 8)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnClassDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto classForwardDeclaration = followHeaderSymbol(34, 7); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(classForwardDeclaration, MatchesHeaderSourceRange(32, 7, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnClassDefinitionInCpp) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto classForwardDeclaration = followSymbol(54, 7); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(classForwardDeclaration, MatchesHeaderSourceRange(48, 7, 8)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnConstructorDeclaration) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto constructorDefinition = followHeaderSymbol(36, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(constructorDefinition, MatchesSourceRange(27, 14, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnConstructorDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto constructorDeclaration = followSymbol(27, 14); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(constructorDeclaration, MatchesHeaderSourceRange(36, 5, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnMemberReference) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto memberDeclaration = followSymbol(39, 10); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(memberDeclaration, MatchesHeaderSourceRange(38, 18, 6)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnMemberDeclaration) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto sameMemberDeclaration = followHeaderSymbol(38, 18); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(sameMemberDeclaration, MatchesHeaderSourceRange(38, 18, 6)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnFunctionReference) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto functionDefinition = followSymbol(66, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionDefinition, MatchesSourceRange(35, 5, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnMemberFunctionReference) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto memberFunctionDefinition = followSymbol(42, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(memberFunctionDefinition, MatchesSourceRange(49, 21, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnFunctionWithoutDefinitionReference) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto functionDeclaration = followSymbol(43, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionDeclaration, MatchesHeaderSourceRange(59, 5, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnFunctionDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto functionDeclaration = followSymbol(35, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionDeclaration, MatchesHeaderSourceRange(52, 5, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnMemberFunctionDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto memberFunctionDeclaration = followSymbol(49, 21); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(memberFunctionDeclaration, MatchesHeaderSourceRange(43, 9, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnMemberFunctionDeclaration) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto memberFunctionDefinition = followHeaderSymbol(43, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(memberFunctionDefinition, MatchesSourceRange(49, 21, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnInclude) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto startOfIncludeFile = followSymbol(25, 13); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(startOfIncludeFile, MatchesHeaderSourceRange(1, 1, 0)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnLocalVariable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto variableDeclaration = followSymbol(39, 6); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(variableDeclaration, MatchesSourceRange(36, 9, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnClassAlias) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto aliasDefinition = followSymbol(36, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(aliasDefinition, MatchesSourceRange(33, 7, 3)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnStaticVariable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto staticVariableDeclaration = followSymbol(40, 27); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(staticVariableDeclaration, MatchesHeaderSourceRange(30, 7, 7)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnFunctionFromOtherClass) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto functionDefinition = followSymbol(62, 39); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionDefinition, MatchesFileSourceRange(cursorPath, 104, 22, 8)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-05 09:54:21 +02:00
										 |  |  | TEST_F(FollowSymbol, DISABLED_CursorOnDefineReference) | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     const auto functionDefinition = followSymbol(66, 43); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionDefinition, MatchesHeaderSourceRange(27, 9, 11)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorInTheMiddleOfNamespace) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(27, 3); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesHeaderSourceRange(28, 11, 6)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorAfterNamespace) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(27, 7); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesFileSourceRange(QString(""), 0, 0, 0)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 16:43:38 +02:00
										 |  |  | TEST_F(FollowSymbol, CursorOnOneSymbolOperatorDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(76, 13); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesSourceRange(72, 9, 9)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnTwoSymbolOperatorDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(80, 15); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesSourceRange(73, 10, 10)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnOneSymbolOperatorDeclaration) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(72, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesSourceRange(76, 10, 9)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(FollowSymbol, CursorOnTwoSymbolOperatorDeclaration) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const auto namespaceDefinition = followSymbol(73, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(namespaceDefinition, MatchesSourceRange(80, 11, 10)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-29 15:49:45 +01:00
										 |  |  | std::unique_ptr<const Data> FollowSymbol::data; | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void FollowSymbol::SetUpTestCase() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-29 15:49:45 +01:00
										 |  |  |     data = std::make_unique<Data>(); | 
					
						
							|  |  |  |     data->document.parse(); | 
					
						
							|  |  |  |     data->headerDocument.parse(); | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FollowSymbol::TearDownTestCase() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-29 15:49:45 +01:00
										 |  |  |     data.reset(); | 
					
						
							| 
									
										
										
										
											2017-07-28 09:48:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // anonymous namespace
 |