Skip to content

Commit 22c8e4d

Browse files
committed
moved a test from TestUnusedFunctions to TestPreprocessor
1 parent 20bed39 commit 22c8e4d

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

test/testpreprocessor.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ class TestPreprocessor : public TestFixture {
298298
TEST_CASE(hashCalculation);
299299

300300
TEST_CASE(standard);
301+
302+
TEST_CASE(writeLocations);
301303
}
302304

303305
template<size_t size>
@@ -2655,6 +2657,30 @@ class TestPreprocessor : public TestFixture {
26552657
ASSERT(!tokenlist.front()); // nothing is tokenized when an unknown standard is provided
26562658
}
26572659
}
2660+
2661+
// TODO: fails because the location information is not be preserved by PreprocessorHelper::getcode()
2662+
void writeLocations()
2663+
{
2664+
const char inc[] = "class A {\n"
2665+
"public:\n"
2666+
" void f() {}\n"
2667+
"};";
2668+
const char code[] = R"(#include "test.h")";
2669+
ScopedFile header("test.h", inc);
2670+
const std::string processed = PreprocessorHelper::getcodeforcfg(settingsDefault, *this, code, "", "test.cpp");
2671+
TODO_ASSERT_EQUALS(
2672+
"\n"
2673+
"#line 1 \"test.h\"\n"
2674+
"class A {\n"
2675+
"public :\n"
2676+
"void f ( ) { }\n"
2677+
"} ;",
2678+
"class A {\n"
2679+
"public :\n"
2680+
"void f ( ) { }\n"
2681+
"} ;",
2682+
processed);
2683+
}
26582684
};
26592685

26602686
REGISTER_TEST(TestPreprocessor)

test/testunusedfunctions.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class TestUnusedFunctions : public TestFixture {
7979
TEST_CASE(entrypointsWinU);
8080
TEST_CASE(entrypointsUnix);
8181

82-
TEST_CASE(includes);
8382
TEST_CASE(virtualFunc);
8483
TEST_CASE(parensInit);
8584
TEST_CASE(typeInCast);
@@ -732,21 +731,6 @@ class TestUnusedFunctions : public TestFixture {
732731
ASSERT_EQUALS("", errout_str());
733732
}
734733

735-
// TODO: fails because the location information is not be preserved by PreprocessorHelper::getcode()
736-
void includes()
737-
{
738-
// #11483
739-
const char inc[] = "class A {\n"
740-
"public:\n"
741-
" void f() {}\n"
742-
"};";
743-
const char code[] = R"(#include "test.h")";
744-
ScopedFile header("test.h", inc);
745-
const std::string processed = PreprocessorHelper::getcodeforcfg(settings, *this, code, "", "test.cpp");
746-
check(processed);
747-
TODO_ASSERT_EQUALS("[test.h:3:6]: (style) The function 'f' is never used. [unusedFunction]\n", "[test.cpp:3:6]: (style) The function 'f' is never used. [unusedFunction]\n", errout_str());
748-
}
749-
750734
void virtualFunc()
751735
{
752736
check("struct D : public B {\n" // #10660

0 commit comments

Comments
 (0)