Skip to content

Commit b86c268

Browse files
committed
TestPreprocessor: Fix output
1 parent d1406d5 commit b86c268

3 files changed

Lines changed: 7 additions & 18 deletions

File tree

lib/preprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ std::string Preprocessor::getcode(const std::string &filedata, const std::string
578578
setDirectives(tokens1);
579579

580580
reportOutput(outputList, true);
581-
581+
582582
if (hasErrors(outputList))
583583
return "";
584584

lib/preprocessor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ class CPPCHECKLIB Preprocessor {
184184
*/
185185
void dump(std::ostream &out) const;
186186

187-
private:
188187
void reportOutput(const simplecpp::OutputList &outputList, bool showerror);
188+
189+
private:
189190
void missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType);
190191
void error(const std::string &filename, unsigned int linenr, const std::string &msg);
191192

test/testpreprocessor.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,9 @@ class TestPreprocessor : public TestFixture {
5353
simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI(), &outputList);
5454

5555
if (errorLogger) {
56-
for (simplecpp::OutputList::const_iterator it = outputList.begin(); it != outputList.end(); ++it) {
57-
const simplecpp::Output &msg = *it;
58-
if (msg.type == simplecpp::Output::ERROR) {
59-
60-
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
61-
ErrorLogger::ErrorMessage::FileLocation loc(msg.location.file(), msg.location.line);
62-
locationList.push_back(loc);
63-
errorLogger->reportErr(ErrorLogger::ErrorMessage(locationList,
64-
emptyString,
65-
Severity::error,
66-
msg.msg,
67-
"preprocessorError",
68-
false));
69-
}
70-
}
56+
Settings settings;
57+
Preprocessor p(settings, errorLogger);
58+
p.reportOutput(outputList, true);
7159
}
7260

7361
return tokens2.stringify();
@@ -1661,7 +1649,7 @@ class TestPreprocessor : public TestFixture {
16611649
// Compare results..
16621650
ASSERT_EQUALS(1, static_cast<unsigned int>(actual.size()));
16631651
ASSERT_EQUALS("", actual[""]);
1664-
ASSERT_EQUALS("[file.c:6]: (error) Syntax error. Wrong number of parameters for macro 'BC'.\n", errout.str());
1652+
ASSERT_EQUALS("[file.c:6]: (error) Wrong number of parameters for macro 'BC'.\n", errout.str());
16651653
}
16661654

16671655
void newline_in_macro() {

0 commit comments

Comments
 (0)