preprocessor: updated the tests. They are now failing.

This commit is contained in:
Daniel Marjamäki 2008-10-28 19:08:05 +00:00
parent ed646d15be
commit c9fa509591
1 changed files with 23 additions and 3 deletions

View File

@ -43,6 +43,8 @@ private:
TEST_CASE( comments1 ); TEST_CASE( comments1 );
TEST_CASE( if0 ); TEST_CASE( if0 );
TEST_CASE( include1 );
} }
bool cmpmaps(const std::map<std::string, std::string> &m1, const std::map<std::string, std::string> &m2) bool cmpmaps(const std::map<std::string, std::string> &m1, const std::map<std::string, std::string> &m2)
@ -50,7 +52,7 @@ private:
// Begin by checking the sizes // Begin by checking the sizes
if ( m1.size() != m2.size() ) if ( m1.size() != m2.size() )
return false; return false;
// Check each item in the maps.. // Check each item in the maps..
for ( std::map<std::string,std::string>::const_iterator it1 = m1.begin(); it1 != m1.end(); ++it1 ) for ( std::map<std::string,std::string>::const_iterator it1 = m1.begin(); it1 != m1.end(); ++it1 )
{ {
@ -96,14 +98,14 @@ private:
void test2() void test2()
{ {
const char filedata[] = "# ifndef WIN32\n" const char filedata[] = "# ifndef WIN32\n"
" \"#ifdef WIN32\" // a comment\n" " \" # ifdef WIN32\" // a comment\n"
" # else \n" " # else \n"
" qwerty\n" " qwerty\n"
" # endif \n"; " # endif \n";
// Expected result.. // Expected result..
std::map<std::string, std::string> expected; std::map<std::string, std::string> expected;
expected[""] = "\n\"............\"\n\n\n\n"; expected[""] = "\n\" # ifdef WIN32\"\n\n\n\n";
expected["WIN32"] = "\n\n\nqwerty\n\n"; expected["WIN32"] = "\n\n\nqwerty\n\n";
// Preprocess => actual result.. // Preprocess => actual result..
@ -160,6 +162,24 @@ private:
} }
void include1()
{
const char filedata[] = " # include \"abcd.h\" // abcd\n";
// Expected result..
std::map<std::string, std::string> expected;
expected[""] = "#include \"abcd.h\"\n";
// Preprocess => actual result..
std::istringstream istr(filedata);
std::map<std::string, std::string> actual;
preprocess( istr, actual );
// Compare results..
ASSERT_EQUALS( true, cmpmaps(actual, expected));
}
}; };
REGISTER_TEST( TestPreprocessor ) REGISTER_TEST( TestPreprocessor )