summaryrefslogtreecommitdiff
path: root/tests/unit/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/unittest')
-rw-r--r--tests/unit/unittest/clangqueryhighlightmarker-test.cpp261
-rw-r--r--tests/unit/unittest/data/highlightingmarks.cpp20
-rw-r--r--tests/unit/unittest/highlightingmarks-test.cpp41
-rw-r--r--tests/unit/unittest/matchingtext-test.cpp259
-rw-r--r--tests/unit/unittest/unittest.pro117
5 files changed, 634 insertions, 64 deletions
diff --git a/tests/unit/unittest/clangqueryhighlightmarker-test.cpp b/tests/unit/unittest/clangqueryhighlightmarker-test.cpp
index 01d9f848f2..05e657b9ea 100644
--- a/tests/unit/unittest/clangqueryhighlightmarker-test.cpp
+++ b/tests/unit/unittest/clangqueryhighlightmarker-test.cpp
@@ -32,12 +32,16 @@
namespace {
using testing::AllOf;
using testing::Contains;
+using testing::ElementsAre;
+using testing::Pointwise;
using testing::IsEmpty;
using testing::Not;
using testing::InSequence;
using testing::_;
using SourceRange = ClangBackEnd::V2::SourceRangeContainer;
+using Message = ClangBackEnd::DynamicASTMatcherDiagnosticMessageContainer;
+using Context = ClangBackEnd::DynamicASTMatcherDiagnosticContextContainer;
using Messages = ClangBackEnd::DynamicASTMatcherDiagnosticMessageContainers;
using Contexts = ClangBackEnd::DynamicASTMatcherDiagnosticContextContainers;
using Marker = ClangRefactoring::ClangQueryHighlightMarker<MockSyntaxHighlighter>;
@@ -54,7 +58,6 @@ protected:
QTextCharFormat contextTextFormat;
MockSyntaxHighlighter highlighter;
Marker marker{highlighter};
-
};
TEST_F(ClangQueryHighlightMarker, NoCallForNoMessagesAndContexts)
@@ -120,6 +123,262 @@ TEST_F(ClangQueryHighlightMarker, CallForMessagesAndContextForAMultiLine)
marker.highlightBlock(3, " ) ");
}
+TEST_F(ClangQueryHighlightMarker, NoMessagesIfEmpty)
+{
+ Messages messages;
+ Contexts contexts;
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundMessages = marker.messagesForLineAndColumn(1, 1);
+
+ ASSERT_THAT(foundMessages, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, NoMessagesForBeforePosition)
+{
+ Messages messages{{{1, 1, 5, 0, 3, 3, 0},
+ ErrorType::RegistryMatcherNotFound,
+ {"foo"}}};
+ Contexts contexts;
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundMessages = marker.messagesForLineAndColumn(1, 4);
+
+ ASSERT_THAT(foundMessages, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, NoMessagesForAfterPosition)
+{
+ Messages messages{{{1, 1, 5, 0, 3, 3, 0},
+ ErrorType::RegistryMatcherNotFound,
+ {"foo"}}};
+ Contexts contexts;
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundMessages = marker.messagesForLineAndColumn(3, 4);
+
+ ASSERT_THAT(foundMessages, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, OneMessagesForInsidePosition)
+{
+ Message message{{1, 1, 5, 0, 3, 3, 0},
+ ErrorType::RegistryMatcherNotFound,
+ {"foo"}};
+ Messages messages{message.clone()};
+ Contexts contexts;
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundMessages = marker.messagesForLineAndColumn(2, 3);
+
+ ASSERT_THAT(foundMessages, ElementsAre(message));
+}
+
+TEST_F(ClangQueryHighlightMarker, NoMessagesForOutsidePosition)
+{
+ Message message{{1, 1, 5, 0, 3, 3, 0},
+ ErrorType::RegistryMatcherNotFound,
+ {"foo"}};
+ Messages messages{message.clone()};
+ Contexts contexts;
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundMessages = marker.messagesForLineAndColumn(3, 4);
+
+ ASSERT_THAT(foundMessages, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, AfterStartColumnBeforeLine)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isAfterStartColumn = marker.isInsideRange(sourceRange, 1, 6);
+
+ ASSERT_FALSE(isAfterStartColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, AfterStartColumnBeforeColumn)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isAfterStartColumn = marker.isInsideRange(sourceRange, 2, 4);
+
+ ASSERT_FALSE(isAfterStartColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, AfterStartColumnAtColumn)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isAfterStartColumn = marker.isInsideRange(sourceRange, 2, 5);
+
+ ASSERT_TRUE(isAfterStartColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, AfterStartColumnAfterColumn)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isAfterStartColumn = marker.isInsideRange(sourceRange, 2, 6);
+
+ ASSERT_TRUE(isAfterStartColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAfterLine)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 4, 1);
+
+ ASSERT_FALSE(isBeforeEndColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAfterColumn)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 3, 4);
+
+ ASSERT_FALSE(isBeforeEndColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, BeforeEndColumnAtColumn)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 3, 3);
+
+ ASSERT_TRUE(isBeforeEndColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, BeforeEndColumnBeforeColumn)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isBeforeEndColumn = marker.isInsideRange(sourceRange, 3, 2);
+
+ ASSERT_TRUE(isBeforeEndColumn);
+}
+
+TEST_F(ClangQueryHighlightMarker, InBetweenLineBeforeLine)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 3, 3, 0};
+
+ bool isInBetween = marker.isInsideRange(sourceRange, 1, 6);
+
+ ASSERT_FALSE(isInBetween);
+}
+
+TEST_F(ClangQueryHighlightMarker, InBetweenLineAfterLine)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 4, 3, 0};
+
+ bool isInBetween = marker.isInsideRange(sourceRange, 5, 1);
+
+ ASSERT_FALSE(isInBetween);
+}
+
+TEST_F(ClangQueryHighlightMarker, InBetweenLine)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 4, 3, 0};
+
+ bool isInBetween = marker.isInsideRange(sourceRange, 3, 1);
+
+ ASSERT_TRUE(isInBetween);
+}
+
+TEST_F(ClangQueryHighlightMarker, SingleLineBefore)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 2, 10, 0};
+
+ bool isInRange = marker.isInsideRange(sourceRange, 2, 4);
+
+ ASSERT_FALSE(isInRange);
+}
+
+TEST_F(ClangQueryHighlightMarker, SingleLineAfter)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 2, 10, 0};
+
+ bool isInRange = marker.isInsideRange(sourceRange, 2, 11);
+
+ ASSERT_FALSE(isInRange);
+}
+
+TEST_F(ClangQueryHighlightMarker, SingleLineInRange)
+{
+ SourceRange sourceRange{1, 2, 5, 0, 2, 10, 0};
+
+ bool isInRange = marker.isInsideRange(sourceRange, 2, 6);
+
+ ASSERT_TRUE(isInRange);
+}
+
+TEST_F(ClangQueryHighlightMarker, NoContextsIfEmpty)
+{
+ Messages messages;
+ Contexts contexts;
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundContexts = marker.contextsForLineAndColumn(1, 1);
+
+ ASSERT_THAT(foundContexts, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, NoContextsForBeforePosition)
+{
+ Messages messages;
+ Contexts contexts{{{1, 1, 5, 0, 3, 3, 0},
+ ContextType::MatcherArg,
+ {"foo"}}};
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundContexts = marker.contextsForLineAndColumn(1, 4);
+
+ ASSERT_THAT(foundContexts, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, NoContextsForAfterPosition)
+{
+ Messages messages;
+ Contexts contexts{{{1, 1, 5, 0, 3, 3, 0},
+ ContextType::MatcherArg,
+ {"foo"}}};
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundContexts = marker.contextsForLineAndColumn(3, 4);
+
+ ASSERT_THAT(foundContexts, IsEmpty());
+}
+
+TEST_F(ClangQueryHighlightMarker, OneContextsForInsidePosition)
+{
+ Context context{{1, 1, 5, 0, 3, 3, 0},
+ ContextType::MatcherArg,
+ {"foo"}};
+ Messages messages;
+ Contexts contexts{context.clone()};
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundContexts = marker.contextsForLineAndColumn(2, 3);
+
+ ASSERT_THAT(foundContexts, ElementsAre(context));
+}
+
+TEST_F(ClangQueryHighlightMarker, NoContextsForOutsidePosition)
+{
+ Context context{{1, 1, 5, 0, 3, 3, 0},
+ ContextType::MatcherArg,
+ {"foo"}};
+ Messages messages;
+ Contexts contexts{context.clone()};
+ marker.setMessagesAndContexts(std::move(messages), std::move(contexts));
+
+ auto foundContexts = marker.contextsForLineAndColumn(3, 4);
+
+ ASSERT_THAT(foundContexts, IsEmpty());
+}
+
void ClangQueryHighlightMarker::SetUp()
{
messageTextFormat.setFontItalic(true);
diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp
index a954df3e97..5b3374d582 100644
--- a/tests/unit/unittest/data/highlightingmarks.cpp
+++ b/tests/unit/unittest/data/highlightingmarks.cpp
@@ -482,12 +482,12 @@ void f25()
NonConstPointerArgument(x);
}
-void ConstPointerArgument(const int *argument);
-
+void PointerToConstArgument(const int *argument);
+void ConstPointerArgument(int *const argument);
void f26()
{
int *x;
-
+ PointerToConstArgument(x);
ConstPointerArgument(x);
}
@@ -565,3 +565,17 @@ void g(OtherOperator o, int var)
{
o(var);
}
+
+void NonConstPointerArgument(int &argument);
+
+struct PointerGetterClass
+{
+ int &getter();
+};
+
+void f32()
+{
+ PointerGetterClass x;
+
+ NonConstPointerArgument(x.getter());
+}
diff --git a/tests/unit/unittest/highlightingmarks-test.cpp b/tests/unit/unittest/highlightingmarks-test.cpp
index e72d25c971..8592bb67be 100644
--- a/tests/unit/unittest/highlightingmarks-test.cpp
+++ b/tests/unit/unittest/highlightingmarks-test.cpp
@@ -60,6 +60,8 @@ using testing::IsNull;
using testing::NotNull;
using testing::Gt;
using testing::Contains;
+using testing::ElementsAre;
+using testing::_;
using testing::EndsWith;
using testing::AllOf;
using testing::Not;
@@ -96,6 +98,14 @@ MATCHER_P2(HasTwoTypes, firstType, secondType,
return arg.hasMainType(firstType) && arg.hasMixinType(secondType);
}
+MATCHER_P(HasMixin, firstType,
+ std::string(negation ? "isn't " : "is ")
+ + PrintToString(firstType)
+ )
+{
+ return arg.hasMixinType(firstType);
+}
+
struct Data {
Data()
{
@@ -998,7 +1008,17 @@ TEST_F(HighlightingMarks, NonConstPointerArgument)
infos[1];
ASSERT_THAT(infos[2],
- HasTwoTypes(HighlightingType::LocalVariable, HighlightingType::OutputArgument));
+ HasOnlyType(HighlightingType::LocalVariable));
+}
+
+TEST_F(HighlightingMarks, PointerToConstArgument)
+{
+ const auto infos = translationUnit.highlightingMarksInRange(sourceRange(490, 31));
+
+ infos[1];
+
+ ASSERT_THAT(infos[2],
+ HasOnlyType(HighlightingType::LocalVariable));
}
TEST_F(HighlightingMarks, ConstPointerArgument)
@@ -1011,6 +1031,23 @@ TEST_F(HighlightingMarks, ConstPointerArgument)
HasOnlyType(HighlightingType::LocalVariable));
}
+TEST_F(HighlightingMarks, NonConstPointerGetterAsArgument)
+{
+ const auto infos = translationUnit.highlightingMarksInRange(sourceRange(580, 41));
+
+ ASSERT_THAT(infos,
+ ElementsAre(_,
+ _,
+ HasMixin(HighlightingType::OutputArgument),
+ HasMixin(HighlightingType::OutputArgument),
+ HasMixin(HighlightingType::OutputArgument),
+ HasMixin(HighlightingType::OutputArgument),
+ HasMixin(HighlightingType::OutputArgument),
+ _,
+ _,
+ _));
+}
+
TEST_F(HighlightingMarks, NonConstReferenceArgumentCallInsideCall)
{
const auto infos = translationUnit.highlightingMarksInRange(sourceRange(501, 64));
@@ -1048,7 +1085,7 @@ TEST_F(HighlightingMarks, NonConstPointerArgumentAsExpression)
infos[1];
ASSERT_THAT(infos[3],
- HasTwoTypes(HighlightingType::LocalVariable, HighlightingType::OutputArgument));
+ HasOnlyType(HighlightingType::LocalVariable));
}
TEST_F(HighlightingMarks, NonConstPointerArgumentAsInstanceWithMember)
diff --git a/tests/unit/unittest/matchingtext-test.cpp b/tests/unit/unittest/matchingtext-test.cpp
new file mode 100644
index 0000000000..d5bfcaddef
--- /dev/null
+++ b/tests/unit/unittest/matchingtext-test.cpp
@@ -0,0 +1,259 @@
+/****************************************************************************
+**
+** 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 <cplusplus/MatchingText.h>
+
+#include <QTextDocument>
+#include <QTextCursor>
+
+#include <memory>
+
+#include <utils/qtcassert.h>
+
+namespace {
+
+class Document {
+public:
+ Document(const QString &documentText, char marker = '@')
+ {
+ QString text = documentText;
+ const int markerIndex = documentText.indexOf(marker);
+ if (markerIndex == -1)
+ return;
+
+ text.replace(markerIndex, 1, "");
+
+ document.reset(new QTextDocument(text));
+ cursor = QTextCursor(document.get());
+ cursor.setPosition(markerIndex);
+ }
+
+ std::unique_ptr<QTextDocument> document;
+ QTextCursor cursor;
+};
+
+using MT = CPlusPlus::MatchingText;
+using IsNextBlockDeeperIndented = MT::IsNextBlockDeeperIndented;
+
+class MatchingText : public testing::Test {
+protected:
+ const IsNextBlockDeeperIndented nextBlockIsIndented = [](const QTextBlock &) { return true; };
+};
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_ForNoInput)
+{
+ const Document document("@");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, ""));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotInEmptyLine)
+{
+ const Document document("@");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_Initializer)
+{
+ const Document document("Type object@");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_AfterFunctionDeclaratorSameLine)
+{
+ const Document document("void g() @");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_AfterFunctionDeclaratorNewLine)
+{
+ const Document document("void g()\n"
+ "@");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_AfterFunctionDeclaratorNewLineAndMore)
+{
+ const Document document("void g()\n"
+ "@\n"
+ "1+1;");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_AfterLambdaDeclarator)
+{
+ const Document document("[]() @");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeOpeningCurlyBrace)
+{
+ const Document document("@{");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_BeforeClosingCurlyBrace)
+{
+ const Document document("@}");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_BeforeClosingBracket)
+{
+ const Document document("@]");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_BeforeClosingParen)
+{
+ const Document document("@)");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_BeforeSemicolon)
+{
+ const Document document("@;");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_BeforeComma)
+{
+ const Document document("@,");
+
+ ASSERT_TRUE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotInCppComment)
+{
+ const Document document("// @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotInCppDoxygenComment)
+{
+ const Document document("//! @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeIndented)
+{
+ const Document document("@\n"
+ " 1+1;");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{", nextBlockIsIndented));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeIndentedWithFollowingComment)
+{
+ const Document document("@\n // comment"
+ " 1+1;");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{", nextBlockIsIndented));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeIndentedWithTextInFront)
+{
+ const Document document("if (true) @\n"
+ " 1+1;");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{", nextBlockIsIndented));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeIndentedOnEmptyLine1)
+{
+ const Document document("if (true)\n"
+ "@\n"
+ " 1+1;");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{", nextBlockIsIndented));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeIndentedOnEmptyLine2)
+{
+ const Document document("if (true)\n"
+ " @\n"
+ " 1+1;");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{", nextBlockIsIndented));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotInTheMiddle)
+{
+ const Document document("if (true) @ true;");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeNamedNamespace)
+{
+ const Document document("namespace X @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeNamedNamespaceWithAttributeSpecifier)
+{
+ const Document document("namespace [[xyz]] X @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeUnnamedNamespace)
+{
+ const Document document("namespace @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeUnnamedNamespaceWithAttributeSpecifier)
+{
+ const Document document("namespace [[xyz]] @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeNestedNamespace)
+{
+ const Document document("namespace X::Y::Z @");
+
+ ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
+}
+
+} // anonymous
diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro
index c227eaede2..be7632ecd5 100644
--- a/tests/unit/unittest/unittest.pro
+++ b/tests/unit/unittest/unittest.pro
@@ -36,37 +36,38 @@ QMAKE_SUBSTITUTES += cpptoolsjson
DEFINES += CPPTOOLS_JSON=\"R\\\"xxx($${cpptoolsjson.output})xxx\\\"\"
SOURCES += \
+ changedfilepathcompressor-test.cpp \
+ clangpathwatcher-test.cpp \
+ clangqueryexamplehighlightmarker-test.cpp \
+ clangqueryhighlightmarker-test.cpp \
clientserverinprocess-test.cpp \
- lineprefixer-test.cpp \
+ clientserveroutsideprocess-test.cpp \
cppprojectfilecategorizer-test.cpp \
cppprojectinfogenerator-test.cpp \
cppprojectpartchooser-test.cpp \
- processevents-utilities.cpp \
+ fakeprocess.cpp \
+ faketimer.cpp \
+ filepath-test.cpp \
+ gtest-creator-printing.cpp \
+ gtest-qt-printing.cpp \
+ lineprefixer-test.cpp \
+ matchingtext-test.cpp \
mimedatabase-utilities.cpp \
+ pchgenerator-test.cpp \
+ pchmanagerclientserverinprocess-test.cpp \
+ pchmanagerclient-test.cpp \
+ pchmanagerserver-test.cpp \
+ processevents-utilities.cpp \
+ projectparts-test.cpp \
+ projectupdater-test.cpp \
readandwritemessageblock-test.cpp \
sizedarray-test.cpp \
smallstring-test.cpp \
+ sourcerangefilter-test.cpp \
spydummy.cpp \
+ stringcache-test.cpp \
unittests-main.cpp \
utf8-test.cpp \
- gtest-qt-printing.cpp \
- gtest-creator-printing.cpp \
- clientserveroutsideprocess-test.cpp \
- clangpathwatcher-test.cpp \
- projectparts-test.cpp \
- stringcache-test.cpp \
- changedfilepathcompressor-test.cpp \
- faketimer.cpp \
- pchgenerator-test.cpp \
- fakeprocess.cpp \
- pchmanagerclient-test.cpp \
- projectupdater-test.cpp \
- pchmanagerserver-test.cpp \
- pchmanagerclientserverinprocess-test.cpp \
- filepath-test.cpp \
- sourcerangefilter-test.cpp \
- clangqueryexamplehighlightmarker-test.cpp \
- clangqueryhighlightmarker-test.cpp
!isEmpty(LIBCLANG_LIBS) {
SOURCES += \
@@ -80,21 +81,25 @@ SOURCES += \
clangcompletioncontextanalyzer-test.cpp \
clangcreateinitialdocumentpreamblejob-test.cpp \
clangdiagnosticfilter-test.cpp \
+ clangdocumentprocessors-test.cpp \
+ clangdocumentprocessor-test.cpp \
clangdocuments-test.cpp \
clangdocument-test.cpp \
- clangdocumentprocessor-test.cpp \
- clangdocumentprocessors-test.cpp \
clangfixitoperation-test.cpp \
clangisdiagnosticrelatedtolocation-test.cpp \
clangjobqueue-test.cpp \
clangjobs-test.cpp \
+ clangparsesupportivetranslationunitjob-test.cpp \
+ clangreferencescollector-test.cpp \
+ clangreparsesupportivetranslationunitjob-test.cpp \
clangrequestdocumentannotationsjob-test.cpp \
clangrequestreferencesjob-test.cpp \
- clangreferencescollector-test.cpp \
clangstring-test.cpp \
- clangtranslationunit-test.cpp \
+ clangsupportivetranslationunitinitializer-test.cpp \
clangtranslationunits-test.cpp \
+ clangtranslationunit-test.cpp \
clangupdatedocumentannotationsjob-test.cpp \
+ codecompleter-test.cpp \
codecompletionsextractor-test.cpp \
completionchunkstotextconverter-test.cpp \
createtablesqlstatementbuilder-test.cpp \
@@ -119,28 +124,24 @@ SOURCES += \
unsavedfiles-test.cpp \
unsavedfile-test.cpp \
utf8positionfromlinecolumn-test.cpp \
- clangparsesupportivetranslationunitjob-test.cpp \
- clangreparsesupportivetranslationunitjob-test.cpp \
- clangsupportivetranslationunitinitializer-test.cpp \
- codecompleter-test.cpp
}
!isEmpty(LIBTOOLING_LIBS) {
SOURCES += \
- clangquery-test.cpp \
clangquerygatherer-test.cpp \
clangqueryprojectfindfilter-test.cpp \
+ clangquery-test.cpp \
+ gtest-clang-printing.cpp \
+ includecollector-test.cpp \
+ pchcreator-test.cpp \
refactoringclientserverinprocess-test.cpp \
refactoringclient-test.cpp \
refactoringcompilationdatabase-test.cpp \
refactoringengine-test.cpp \
refactoringserver-test.cpp \
- symbolfinder-test.cpp \
sourcerangeextractor-test.cpp \
- gtest-clang-printing.cpp \
+ symbolfinder-test.cpp \
testclangtool.cpp \
- includecollector-test.cpp \
- pchcreator-test.cpp
}
exists($$GOOGLEBENCHMARK_DIR) {
@@ -149,53 +150,53 @@ SOURCES += \
}
HEADERS += \
+ compare-operators.h \
+ conditionally-disabled-tests.h \
+ dummyclangipcclient.h \
+ dynamicastmatcherdiagnosticcontainer-matcher.h \
+ fakeprocess.h \
+ faketimer.h \
filesystem-utilities.h \
googletest.h \
+ gtest-creator-printing.h \
gtest-qt-printing.h \
- processevents-utilities.h \
mimedatabase-utilities.h \
- spydummy.h \
- sourcerangecontainer-matcher.h \
- dynamicastmatcherdiagnosticcontainer-matcher.h \
- mocksearchresult.h \
- mocksearch.h \
- mocksearchhandle.h \
- compare-operators.h \
- gtest-creator-printing.h \
- conditionally-disabled-tests.h \
- mockqfilesystemwatcher.h \
+ mockchangedfilepathcompressor.h \
+ mockclangcodemodelclient.h \
+ mockclangcodemodelserver.h \
mockclangpathwatcher.h \
- mockprojectparts.h \
mockclangpathwatchernotifier.h \
- mockchangedfilepathcompressor.h \
- faketimer.h \
+ mockpchcreator.h \
mockpchgeneratornotifier.h \
- fakeprocess.h \
- mockpchmanagerserver.h \
mockpchmanagerclient.h \
- testenvironment.h \
mockpchmanagernotifier.h \
- mockpchcreator.h \
- dummyclangipcclient.h \
- mockclangcodemodelclient.h \
- mockclangcodemodelserver.h \
- mocksyntaxhighligher.h
+ mockpchmanagerserver.h \
+ mockprojectparts.h \
+ mockqfilesystemwatcher.h \
+ mocksearch.h \
+ mocksearchhandle.h \
+ mocksearchresult.h \
+ mocksyntaxhighligher.h \
+ processevents-utilities.h \
+ sourcerangecontainer-matcher.h \
+ spydummy.h \
+ testenvironment.h \
!isEmpty(LIBCLANG_LIBS) {
HEADERS += \
chunksreportedmonitor.h \
clangasyncjob-base.h \
+ clangcompareoperators.h \
diagnosticcontainer-matcher.h \
- clangcompareoperators.h
}
!isEmpty(LIBTOOLING_LIBS) {
HEADERS += \
+ gtest-clang-printing.h \
mockrefactoringclientcallback.h \
mockrefactoringclient.h \
mockrefactoringserver.h \
- gtest-clang-printing.h \
- testclangtool.h
+ testclangtool.h \
}
OTHER_FILES += $$files(data/*)