From 997a784bb65c54f57ffabd407acefd3614d8da9a Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 13 May 2009 00:01:53 +0300 Subject: [PATCH] Added TODO test case TestPreprocessor::multiline_comment Made tokenizer to printout token list in case of syntax error, if debug is used --- src/tokenize.cpp | 5 +++++ test/testpreprocessor.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 623c678c9..735745670 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -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; diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index b2303f10e..cfa7755b8 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -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 actual; + Preprocessor preprocessor; + preprocessor.preprocess(istr, actual, "file.c"); + + // Compare results.. + ASSERT_EQUALS(1, static_cast(actual.size())); + TODO_ASSERT_EQUALS("\n\nvoid f() { }\n", actual[""]); + ASSERT_EQUALS("", errout.str()); + } + + + }; REGISTER_TEST(TestPreprocessor)