summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2017-02-13 13:30:29 +0100
committerMarco Bubke <marco.bubke@qt.io>2017-02-16 17:39:16 +0000
commitaba09cc115bddb008913d4a14bdfb0d1f44fa44f (patch)
tree871cb5196e0c7794ce70537f4a22587e6587c16b /tests
parent1a75db12f469ee21b2761abe0da06f931bfb1408 (diff)
downloadqt-creator-aba09cc115bddb008913d4a14bdfb0d1f44fa44f.tar.gz
Clang: Add test for include collector
To be secure that include is only called it the definition is true. Change-Id: I04bae9860e64206a1c6886d7cf1682a87e9f9a07 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unittest/data/includecollector_false.h2
-rw-r--r--tests/unit/unittest/data/includecollector_if.cpp7
-rw-r--r--tests/unit/unittest/data/includecollector_true.h2
-rw-r--r--tests/unit/unittest/includecollector-test.cpp10
4 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/unittest/data/includecollector_false.h b/tests/unit/unittest/data/includecollector_false.h
new file mode 100644
index 0000000000..3f59c932d3
--- /dev/null
+++ b/tests/unit/unittest/data/includecollector_false.h
@@ -0,0 +1,2 @@
+#pragma once
+
diff --git a/tests/unit/unittest/data/includecollector_if.cpp b/tests/unit/unittest/data/includecollector_if.cpp
new file mode 100644
index 0000000000..fab79180e2
--- /dev/null
+++ b/tests/unit/unittest/data/includecollector_if.cpp
@@ -0,0 +1,7 @@
+#if 0
+#include "includecollector_false.h"
+#endif
+
+#if 1
+#include "includecollector_true.h"
+#endif
diff --git a/tests/unit/unittest/data/includecollector_true.h b/tests/unit/unittest/data/includecollector_true.h
new file mode 100644
index 0000000000..3f59c932d3
--- /dev/null
+++ b/tests/unit/unittest/data/includecollector_true.h
@@ -0,0 +1,2 @@
+#pragma once
+
diff --git a/tests/unit/unittest/includecollector-test.cpp b/tests/unit/unittest/includecollector-test.cpp
index 8de9c04f78..eacfbcebb7 100644
--- a/tests/unit/unittest/includecollector-test.cpp
+++ b/tests/unit/unittest/includecollector-test.cpp
@@ -87,6 +87,16 @@ TEST_F(IncludeCollector, IncludesAreSorted)
ElementsAre(0, 1, 2));
}
+TEST_F(IncludeCollector, If)
+{
+ emptyCollector.addFile(TESTDATA_DIR, "includecollector_if.cpp", "", {"cc", "includecollector_if.cpp"});
+
+ emptyCollector.collectIncludes();
+
+ ASSERT_THAT(emptyCollector.takeIncludeIds(),
+ ElementsAre(id(TESTDATA_DIR "/includecollector_true.h")));
+}
+
TEST_F(IncludeCollector, LocalPath)
{
emptyCollector.addFile(TESTDATA_DIR, "includecollector_main.cpp", "", {"cc", "includecollector_main.cpp"});