Added TODO test case TestPreprocessor::multiline_comment

Made tokenizer to printout token list in case of syntax error, if debug is used
This commit is contained in:
Reijo Tomperi 2009-05-13 00:01:53 +03:00
parent 31f315d2ec
commit 997a784bb6
2 changed files with 27 additions and 0 deletions

View File

@ -2670,6 +2670,11 @@ const Token * Tokenizer::FindClassFunction(const Token *tok, const char classnam
void Tokenizer::syntaxError(const Token *tok, char c)
{
if (_settings._debug)
{
_tokens->printOut();
}
if (!_errorLogger)
{
std::cout << "### Unlogged error at Tokenizer::syntaxError" << std::endl;

View File

@ -122,6 +122,7 @@ private:
TEST_CASE(unicode1);
TEST_CASE(define_part_of_func);
TEST_CASE(multiline_comment);
}
@ -928,6 +929,27 @@ private:
ASSERT_EQUALS("", errout.str());
}
void multiline_comment()
{
errout.str("");
const char filedata[] = "#define ABC {// \\\n"
"}\n"
"void f() ABC }\n";
// Preprocess => actual result..
std::istringstream istr(filedata);
std::map<std::string, std::string> actual;
Preprocessor preprocessor;
preprocessor.preprocess(istr, actual, "file.c");
// Compare results..
ASSERT_EQUALS(1, static_cast<unsigned int>(actual.size()));
TODO_ASSERT_EQUALS("\n\nvoid f() { }\n", actual[""]);
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestPreprocessor)