From c9fa509591121010228aa709c0f0df97cfbe4ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 28 Oct 2008 19:08:05 +0000 Subject: [PATCH] preprocessor: updated the tests. They are now failing. --- testpreprocessor.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/testpreprocessor.cpp b/testpreprocessor.cpp index 70e4a4f8a..d134558da 100644 --- a/testpreprocessor.cpp +++ b/testpreprocessor.cpp @@ -43,6 +43,8 @@ private: TEST_CASE( comments1 ); TEST_CASE( if0 ); + + TEST_CASE( include1 ); } bool cmpmaps(const std::map &m1, const std::map &m2) @@ -50,7 +52,7 @@ private: // Begin by checking the sizes if ( m1.size() != m2.size() ) return false; - + // Check each item in the maps.. for ( std::map::const_iterator it1 = m1.begin(); it1 != m1.end(); ++it1 ) { @@ -96,14 +98,14 @@ private: void test2() { const char filedata[] = "# ifndef WIN32\n" - " \"#ifdef WIN32\" // a comment\n" + " \" # ifdef WIN32\" // a comment\n" " # else \n" " qwerty\n" " # endif \n"; // Expected result.. std::map expected; - expected[""] = "\n\"............\"\n\n\n\n"; + expected[""] = "\n\" # ifdef WIN32\"\n\n\n\n"; expected["WIN32"] = "\n\n\nqwerty\n\n"; // Preprocess => actual result.. @@ -160,6 +162,24 @@ private: } + + void include1() + { + const char filedata[] = " # include \"abcd.h\" // abcd\n"; + + // Expected result.. + std::map expected; + expected[""] = "#include \"abcd.h\"\n"; + + // Preprocess => actual result.. + std::istringstream istr(filedata); + std::map actual; + preprocess( istr, actual ); + + // Compare results.. + ASSERT_EQUALS( true, cmpmaps(actual, expected)); + } + }; REGISTER_TEST( TestPreprocessor )