Skip to content

Commit 66c8a45

Browse files
committed
PreprocessorHelper: moved getRemarkComments() to TestPreprocessor
1 parent 62a92a6 commit 66c8a45

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

test/helpers.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,6 @@ void PreprocessorHelper::preprocess(const char code[], std::vector<std::string>
202202
tokenizer.setDirectives(std::move(directives));
203203
}
204204

205-
std::vector<RemarkComment> PreprocessorHelper::getRemarkComments(const char code[], ErrorLogger& errorLogger)
206-
{
207-
std::vector<std::string> files{"test.cpp"};
208-
std::istringstream istr(code);
209-
const simplecpp::TokenList tokens1(istr, files, files[0]);
210-
211-
const Settings settings;
212-
213-
const Preprocessor preprocessor(settings, errorLogger);
214-
return preprocessor.getRemarkComments(tokens1);
215-
}
216-
217205
bool LibraryHelper::loadxmldata(Library &lib, const char xmldata[], std::size_t len)
218206
{
219207
tinyxml2::XMLDocument doc;

test/helpers.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ class PreprocessorHelper
175175
static void preprocess(const char code[], std::vector<std::string> &files, Tokenizer& tokenizer, ErrorLogger& errorlogger);
176176
static void preprocess(const char code[], std::vector<std::string> &files, Tokenizer& tokenizer, ErrorLogger& errorlogger, const simplecpp::DUI& dui);
177177

178-
/** get remark comments */
179-
static std::vector<RemarkComment> getRemarkComments(const char code[], ErrorLogger& errorLogger);
180-
181178
private:
182179
static std::map<std::string, std::string> getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set<std::string> cfgs, const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr);
183180
};

test/testpreprocessor.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ class TestPreprocessor : public TestFixture {
6060
return tokens2.stringify();
6161
}
6262

63+
static std::vector<RemarkComment> getRemarkComments(const char code[], ErrorLogger& errorLogger)
64+
{
65+
std::vector<std::string> files{"test.cpp"};
66+
std::istringstream istr(code);
67+
const simplecpp::TokenList tokens1(istr, files, files[0]);
68+
69+
const Settings settings;
70+
71+
const Preprocessor preprocessor(settings, errorLogger);
72+
return preprocessor.getRemarkComments(tokens1);
73+
}
74+
6375
const Settings settings0 = settingsBuilder().severity(Severity::information).build();
6476

6577
void run() override {
@@ -1917,15 +1929,15 @@ class TestPreprocessor : public TestFixture {
19171929
void remarkComment1() {
19181930
const char code[] = "// REMARK: assignment with 1\n"
19191931
"x=1;\n";
1920-
const auto remarkComments = PreprocessorHelper::getRemarkComments(code, *this);
1932+
const auto remarkComments = getRemarkComments(code, *this);
19211933
ASSERT_EQUALS(1, remarkComments.size());
19221934
ASSERT_EQUALS(2, remarkComments[0].lineNumber);
19231935
ASSERT_EQUALS("assignment with 1", remarkComments[0].str);
19241936
}
19251937

19261938
void remarkComment2() {
19271939
const char code[] = "x=1; ///REMARK assignment with 1\n";
1928-
const auto remarkComments = PreprocessorHelper::getRemarkComments(code, *this);
1940+
const auto remarkComments = getRemarkComments(code, *this);
19291941
ASSERT_EQUALS(1, remarkComments.size());
19301942
ASSERT_EQUALS(1, remarkComments[0].lineNumber);
19311943
ASSERT_EQUALS("assignment with 1", remarkComments[0].str);
@@ -1934,7 +1946,7 @@ class TestPreprocessor : public TestFixture {
19341946
void remarkComment3() {
19351947
const char code[] = "/** REMARK: assignment with 1 */\n"
19361948
"x=1;\n";
1937-
const auto remarkComments = PreprocessorHelper::getRemarkComments(code, *this);
1949+
const auto remarkComments = getRemarkComments(code, *this);
19381950
ASSERT_EQUALS(1, remarkComments.size());
19391951
ASSERT_EQUALS(2, remarkComments[0].lineNumber);
19401952
ASSERT_EQUALS("assignment with 1 ", remarkComments[0].str);

0 commit comments

Comments
 (0)