| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:55:33 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** 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 | 
					
						
							| 
									
										
										
										
											2016-01-15 14:55:33 +01:00
										 |  |  | ** 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.
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:55:33 +01:00
										 |  |  | ** 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.
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-15 17:41:41 +02:00
										 |  |  | #include "googletest.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | #include "clangcompareoperators.h"
 | 
					
						
							| 
									
										
										
										
											2017-05-23 09:49:22 +02:00
										 |  |  | #include "testenvironment.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-07 10:42:12 +02:00
										 |  |  | #include <clangdocument.h>
 | 
					
						
							|  |  |  | #include <clangdocuments.h>
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | #include <clangstring.h>
 | 
					
						
							|  |  |  | #include <cursor.h>
 | 
					
						
							|  |  |  | #include <sourcelocation.h>
 | 
					
						
							|  |  |  | #include <sourcerange.h>
 | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  | #include <clangtranslationunit.h>
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | #include <unsavedfiles.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using ClangBackEnd::Cursor; | 
					
						
							| 
									
										
										
										
											2016-09-07 10:42:12 +02:00
										 |  |  | using ClangBackEnd::Document; | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  | using ClangBackEnd::TranslationUnit; | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | using ClangBackEnd::UnsavedFiles; | 
					
						
							| 
									
										
										
										
											2016-09-07 10:42:12 +02:00
										 |  |  | using ClangBackEnd::Documents; | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | using ClangBackEnd::ClangString; | 
					
						
							|  |  |  | using ClangBackEnd::SourceRange; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using testing::IsNull; | 
					
						
							|  |  |  | using testing::NotNull; | 
					
						
							|  |  |  | using testing::Gt; | 
					
						
							|  |  |  | using testing::Contains; | 
					
						
							|  |  |  | using testing::EndsWith; | 
					
						
							|  |  |  | using testing::AllOf; | 
					
						
							|  |  |  | using testing::Not; | 
					
						
							|  |  |  | using testing::IsEmpty; | 
					
						
							|  |  |  | using testing::StrEq; | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  | using testing::Eq; | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct Data { | 
					
						
							|  |  |  |     ClangBackEnd::UnsavedFiles unsavedFiles; | 
					
						
							| 
									
										
										
										
											2018-09-25 09:41:32 +02:00
										 |  |  |     ClangBackEnd::Documents documents{unsavedFiles}; | 
					
						
							| 
									
										
										
										
											2016-06-05 19:59:23 +02:00
										 |  |  |     Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/cursor.cpp")}; | 
					
						
							| 
									
										
										
										
											2016-09-07 10:42:12 +02:00
										 |  |  |     Document document{filePath, | 
					
						
							| 
									
										
										
										
											2018-09-25 09:41:32 +02:00
										 |  |  |                       TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")}), | 
					
						
							| 
									
										
										
										
											2018-10-19 10:20:27 +02:00
										 |  |  |                       {}, | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |                       documents}; | 
					
						
							|  |  |  |     TranslationUnit translationUnit{filePath, | 
					
						
							| 
									
										
										
										
											2016-09-13 10:41:22 +02:00
										 |  |  |                                     filePath, | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |                                     document.translationUnit().cxIndex(), | 
					
						
							|  |  |  |                                     document.translationUnit().cxTranslationUnit()}; | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Cursor : public ::testing::Test | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     static void SetUpTestCase(); | 
					
						
							|  |  |  |     static void TearDownTestCase(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  |     static Data *d; | 
					
						
							| 
									
										
										
										
											2016-09-07 10:42:12 +02:00
										 |  |  |     const Document &document = d->document; | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     const TranslationUnit &translationUnit = d->translationUnit; | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | TEST_F(Cursor, CreateNullCursor) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::Cursor cursor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isNull()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CompareNullCursors) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::Cursor cursor; | 
					
						
							|  |  |  |     ::Cursor cursor2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor, cursor2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsNotValid) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::Cursor cursor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.isValid()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsValid) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursor(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isValid()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsTranslationUnit) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursor(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isTranslationUnit()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, NullCursorIsNotTranslationUnit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::Cursor cursor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.isTranslationUnit()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, UnifiedSymbolResolution) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |      ::Cursor cursor; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  |      ASSERT_FALSE(cursor.unifiedSymbolResolution().hasContent()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, GetCursorAtLocation) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(3, 6); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  |     ASSERT_THAT(cursor.unifiedSymbolResolution(), Eq("c:@F@function#I#")); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, GetCursoSourceLocation) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(3, 6); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     ASSERT_THAT(cursor.sourceLocation(), translationUnit.sourceLocationAt(3, 6)); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, GetCursoSourceRange) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(3, 6); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     ASSERT_THAT(cursor.sourceRange(), SourceRange(translationUnit.sourceLocationAt(3, 1), | 
					
						
							|  |  |  |                                                   translationUnit.sourceLocationAt(6, 2))); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, Mangling) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(3, 6); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  |     ASSERT_TRUE(cursor.mangling().hasContent()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, Spelling) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(3, 6); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.spelling().cString(), StrEq("function")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, DisplayName) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(3, 6); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  |     ASSERT_THAT(cursor.displayName(), Eq("function(int)")); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, BriefComment) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  |     ASSERT_THAT(cursor.briefComment(), Eq("A brief comment")); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-25 10:04:42 +02:00
										 |  |  | TEST_F(Cursor, RawComment) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 16:04:45 +02:00
										 |  |  |     ASSERT_THAT(cursor.rawComment(), Eq("/**\n * A brief comment\n */")); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CommentRange) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.commentRange(), | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |                 SourceRange(translationUnit.sourceLocationAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 7, 1), | 
					
						
							|  |  |  |                             translationUnit.sourceLocationAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 9, 4))); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsDefinition) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isDefinition()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ForwardDeclarationIsNotDefinition) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 6, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.isDefinition()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, GetDefinitionOfFowardDeclaration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto forwardDeclarationcursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 6, 7); | 
					
						
							|  |  |  |     auto definitionCursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(forwardDeclarationcursor.definition(), definitionCursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CallToMethodeIsNotDynamic) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(18, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.isDynamicCall()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CallToAbstractVirtualMethodeIsDynamic) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(19, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isDynamicCall()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CanonicalCursor) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto forwardDeclarationcursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 6, 7); | 
					
						
							|  |  |  |     auto definitionCursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(definitionCursor.canonical(), forwardDeclarationcursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ReferencedCursor) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto functionCallCursor = translationUnit.cursorAt(18, 5); | 
					
						
							|  |  |  |     auto functionCursor = translationUnit.cursorAt(16, 17); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionCallCursor.referenced(), functionCursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsVirtual) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 15, 17); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isVirtualMethod()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsNotPureVirtualOnlyVirtual) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 15, 17); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.isPureVirtualMethod()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsPureVirtual) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 16, 17); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isPureVirtualMethod()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ConstantMethod) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(31, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isConstantMethod()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsStaticMethod) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(36, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isStaticMethod()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, TypeSpelling) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(43, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.type().utf8Spelling(), Utf8StringLiteral("lint")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CanonicalTypeSpelling) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(43, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.type().canonical().utf8Spelling(), Utf8StringLiteral("long long")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CanonicalTypeCStringSpelling) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(43, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto spelling = cursor.type().canonical().spelling(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(spelling.cString(), StrEq("long long")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CanonicalTypeIsNotType) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(43, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.type().canonical(), Not(cursor.type())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, TypeDeclartionIsAlias) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto declarationCursor = translationUnit.cursorAt(41, 5); | 
					
						
							|  |  |  |     auto lintCursor = translationUnit.cursorAt(39, 11); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(declarationCursor.type().declaration().type(), lintCursor.type()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, TypeIsConstantWithoutAliasLookup) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(45, 16); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.type().isConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ClassIsCompoundType) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 10, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isCompoundType()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, StructIsCompoundType) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 28, 8); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isCompoundType()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, UnionIsCompoundType) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 33, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isCompoundType()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsDeclaration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(41, 10); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isDeclaration()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, SemanticParent) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(43, 6); | 
					
						
							|  |  |  |     auto expectedSemanticParent = translationUnit.cursorAt(36, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto semanticParent = cursor.semanticParent(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(semanticParent, expectedSemanticParent); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLocalVariableInMethod) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(20, 9); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLocalVariableInStaticFunction) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(43, 5); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-23 09:49:22 +02:00
										 |  |  | TEST_F(Cursor, IsLocalVariableInTemplateFunction) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(52, 7); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLocalVariableInConversionOperator) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(57, 9); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLocalVariableInOperator) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(62, 9); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLocalVariableInConstructor) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(13, 9); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLocalVariableInDestructor) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(69, 9); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.isLocalVariable()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, FindFunctionCaller) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto functionCursor = translationUnit.cursorAt(92, 24); | 
					
						
							|  |  |  |     auto structCursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 28, 8); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionCursor.functionBaseDeclaration(), structCursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, FindFunctionCallerPointer) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto functionCursor = translationUnit.cursorAt(79, 25); | 
					
						
							|  |  |  |     auto structCursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 28, 8); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionCursor.functionBaseDeclaration(), structCursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, FindFunctionCallerThis) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto functionCursor = translationUnit.cursorAt(106, 5); | 
					
						
							|  |  |  |     auto structCursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 38, 8); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(functionCursor.functionBaseDeclaration(), structCursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, NonPointerTypeForValue) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto variableCursor = translationUnit.cursorAt(101, 10); | 
					
						
							|  |  |  |     auto variablePointerCursor = translationUnit.cursorAt(100, 11); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(variableCursor.nonPointerTupe(), variablePointerCursor.nonPointerTupe()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, HasFinalAttributeInFunction) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 30, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.hasFinalFunctionAttribute()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, HasNotFinalAttributeInFunction) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 15, 17); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.hasFinalFunctionAttribute()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, HasFinalAttributeInClass) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 28, 8); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(cursor.hasFinalClassAttribute()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, HasNotFinaAttributeInClass) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(Utf8StringLiteral(TESTDATA_DIR"/cursor.h"), 38, 8); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(cursor.hasFinalClassAttribute()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, HasOutputValues) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(117, 19); | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     auto outputArgumentExpectedSourceLocation = translationUnit.cursorAt(117, 20).cxSourceRange(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     auto outputArgumentLocations = callExpressionCursor.outputArgumentRanges(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 18:03:52 +02:00
										 |  |  |     ASSERT_THAT(outputArgumentLocations.size(), 1); | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     ASSERT_THAT(outputArgumentLocations[0], outputArgumentExpectedSourceLocation); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, HasOnlyInputValues) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(118, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     auto outputArgumentLocations = callExpressionCursor.outputArgumentRanges(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     ASSERT_THAT(outputArgumentLocations, IsEmpty()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ArgumentCountIsZero) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(121, 23); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto count = cursor.type().argumentCount(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(count, 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ArgumentCountIsTwo) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(122, 22); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto count = cursor.type().argumentCount(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(count, 2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ArgumentOneIsValue) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(122, 22); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isConstant()); | 
					
						
							|  |  |  |     ASSERT_THAT(argument.kind(), CXType_Int); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ArgumentTwoIsLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(122, 22); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(argument.kind(), CXType_LValueReference); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ArgumentTwoIsConstantReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(122, 22); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argumentPointee = callExpressionCursor.type().argument(1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argumentPointee.isConstantReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CursorArgumentCount) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto cursor = translationUnit.cursorAt(117, 19); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.kind(), CXCursor_CallExpr); | 
					
						
							|  |  |  |     ASSERT_THAT(cursor.argumentCount(), 4); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, CursorArgumentInputValue) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(117, 19); | 
					
						
							|  |  |  |     auto declarationReferenceExpressionCursor = translationUnit.cursorAt(117, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(callExpressionCursor.argument(0), declarationReferenceExpressionCursor); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsConstantLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(125, 26); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isConstantReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, LValueReferenceIsNotConstantLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(124, 21); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isConstantReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ValueIsNotConstantLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(123, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isConstantReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerToConstantNotConstantLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(126, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isConstantReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(124, 21); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isLValueReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ConstantLValueReferenceIsLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(125, 26); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isLValueReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ValueIsNotLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(123, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isLValueReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerIsNotLValueReference) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(126, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isLValueReference()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerToConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(126, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isPointerToConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ValueIsNotPointerToConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(123, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isPointerToConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerNotPointerToConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(127, 13); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isPointerToConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ConstantLValueReferenceIsNotPointerToConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(125, 26); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isPointerToConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, IsConstantPointer) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(128, 21); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isConstantPointer()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerToConstantIsNotConstantPointer) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(126, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isConstantPointer()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ConstValueIsNotConstantPointer) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(129, 23); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isConstantPointer()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerToConstantIsReferencingConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(126, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isReferencingConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ConstantReferenceIsReferencingConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(125, 26); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_TRUE(argument.isReferencingConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, LValueReferenceIsNotReferencingConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(124, 21); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isReferencingConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ValueIsNotReferencingConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(123, 18); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isReferencingConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PointerIsNotRefencingConstant) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(127, 13); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_FALSE(argument.isReferencingConstant()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 18:03:52 +02:00
										 |  |  | TEST_F(Cursor, PointerIsNotOutputArgument) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(127, 13); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 18:03:52 +02:00
										 |  |  |     ASSERT_FALSE(argument.isOutputArgument()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | TEST_F(Cursor, ConstantReferenceIsNotOutputArgument) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(125, 26); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     ASSERT_FALSE(argument.isOutputArgument()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | TEST_F(Cursor, PointerToConstantIsNotOutputArgument) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(126, 20); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     ASSERT_FALSE(argument.isOutputArgument()) << argument.isConstant() << argument.pointeeType().isConstant(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | TEST_F(Cursor, ConstantPointerIsNotOutputArgument) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(128, 21); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 18:03:52 +02:00
										 |  |  |     ASSERT_FALSE(argument.isOutputArgument()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | TEST_F(Cursor, ReferenceIsOutputArgument) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(124, 21); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     ASSERT_TRUE(argument.isOutputArgument()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  | TEST_F(Cursor, ConstReferenceIsNotOutputArgument) | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-09-07 14:50:58 +02:00
										 |  |  |     auto callExpressionCursor = translationUnit.cursorAt(125, 26); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto argument = callExpressionCursor.type().argument(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 18:19:12 +02:00
										 |  |  |     ASSERT_FALSE(argument.isOutputArgument()); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-12 09:44:05 +01:00
										 |  |  | TEST_F(Cursor, ResultType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto methodCursor = translationUnit.cursorAt(31, 18); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Utf8String resultType = methodCursor.type().resultType().spelling(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(resultType, Utf8String("bool", 4)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PrivateMethodAccessSpecifier) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto methodCursor = translationUnit.cursorAt(16, 17); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto accessSpecifier = methodCursor.accessSpecifier(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(accessSpecifier, ClangBackEnd::AccessSpecifier::Private); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PublicMethodAccessSpecifier) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto methodCursor = translationUnit.cursorAt(79, 25); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto accessSpecifier = methodCursor.accessSpecifier(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(accessSpecifier, ClangBackEnd::AccessSpecifier::Public); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ProtectedMethodAccessSpecifier) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto methodCursor = translationUnit.cursorAt(131, 22); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto accessSpecifier = methodCursor.accessSpecifier(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(accessSpecifier, ClangBackEnd::AccessSpecifier::Protected); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, PrivateFieldAccessSpecifier) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto fieldCursor = translationUnit.cursorAt(21, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto accessSpecifier = fieldCursor.accessSpecifier(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(accessSpecifier, ClangBackEnd::AccessSpecifier::Private); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, InvalidAccessSpecifier) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto localVarCursor = translationUnit.cursorAt(62, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto accessSpecifier = localVarCursor.accessSpecifier(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(accessSpecifier, ClangBackEnd::AccessSpecifier::Invalid); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, NoStorageClass) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto localVarCursor = translationUnit.cursorAt(62, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto storageClass = localVarCursor.storageClass(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(storageClass, ClangBackEnd::StorageClass::None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, ExternVarStorageClass) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto externalVarCursor = translationUnit.cursorAt(133, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto storageClass = externalVarCursor.storageClass(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(storageClass, ClangBackEnd::StorageClass::Extern); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, StaticMethodStorageClass) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto methodCursor = translationUnit.cursorAt(135, 13); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto storageClass = methodCursor.storageClass(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(storageClass, ClangBackEnd::StorageClass::Static); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(Cursor, InvalidStorageClass) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto functionTemplateCursor = translationUnit.cursorAt(137, 28); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto storageClass = functionTemplateCursor.storageClass(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(storageClass, ClangBackEnd::StorageClass::Invalid); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | Data *Cursor::d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Cursor::SetUpTestCase() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d = new Data; | 
					
						
							| 
									
										
										
										
											2016-09-07 10:42:12 +02:00
										 |  |  |     d->document.parse(); | 
					
						
							| 
									
										
										
										
											2015-11-17 13:33:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Cursor::TearDownTestCase() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete d; | 
					
						
							|  |  |  |     d = nullptr; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |