aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2017-11-29 16:03:33 +0100
committerMarco Bubke <marco.bubke@qt.io>2017-12-05 10:26:00 +0000
commit872f3ee9c3f532b023099fdfa0001cd4fe8b378b (patch)
treedd7164f53b42811c605be3dcf5e205efd7563d62 /tests
parentd755986827ef9915582188dd05b179e7146c5b9b (diff)
UnitTests: Cleanup ReferencesCollector test
Change-Id: I5c6d25e28116fb7e608044c2c187ff64bfcac9c9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unittest/clangreferencescollector-test.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/tests/unit/unittest/clangreferencescollector-test.cpp b/tests/unit/unittest/clangreferencescollector-test.cpp
index 4fae0785ea1..d0077c475f2 100644
--- a/tests/unit/unittest/clangreferencescollector-test.cpp
+++ b/tests/unit/unittest/clangreferencescollector-test.cpp
@@ -74,11 +74,6 @@ std::ostream &operator<<(std::ostream &os, const ReferencesResult &value)
}
struct Data {
- Data()
- {
- document.parse();
- }
-
ProjectPart projectPart{
Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})};
@@ -96,12 +91,12 @@ class ReferencesCollector : public ::testing::Test
protected:
ReferencesResult getReferences(uint line, uint column)
{
- return d->document.translationUnit().references(line, column);
+ return document.translationUnit().references(line, column);
}
SourceLocationContainer createSourceLocation(uint line, uint column) const
{
- return SourceLocationContainer(d->document.filePath(), line, column);
+ return SourceLocationContainer(document.filePath(), line, column);
}
SourceRangeContainer createSourceRange(uint line, uint column, uint length) const
@@ -115,8 +110,9 @@ protected:
static void SetUpTestCase();
static void TearDownTestCase();
-private:
- static std::unique_ptr<Data> d;
+protected:
+ static std::unique_ptr<const Data> data;
+ const Document &document{data->document};
};
// This test is not strictly needed as the plugin is supposed to put the cursor
@@ -467,16 +463,18 @@ TEST_F(ReferencesCollector, ArgumentToFunctionLikeMacro)
ASSERT_THAT(actual, expected);
}
-std::unique_ptr<Data> ReferencesCollector::d;
+std::unique_ptr<const Data> ReferencesCollector::data;
void ReferencesCollector::SetUpTestCase()
{
- d.reset(new Data);
+ data = std::make_unique<const Data>();
+
+ data->document.parse();
}
void ReferencesCollector::TearDownTestCase()
{
- d.reset();
+ data.reset();
}
} // anonymous namespace