From de2ee0a29df715983dc8e30a36305309110ce2b6 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 11 Feb 2009 22:15:22 +0000 Subject: [PATCH] Test case TestTokenizer::simplify_constants added (commented out) --- test/testtokenize.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 6b9046678..2401295b0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -110,6 +110,7 @@ private: TEST_CASE(simplify_numeric_condition); TEST_CASE(tokenize_double); TEST_CASE(tokenize_strings); + // TODO TEST_CASE(simplify_constants); } @@ -1036,6 +1037,32 @@ private: ostr << " " << tok->str(); ASSERT_EQUALS(std::string(" void f ( ) { const char * a = { \"hello more world\" } ; }"), ostr.str()); } + + void simplify_constants() + { + const char code[] = + "void f()\n" + "{\n" + "const int a = 45;\n" + "}\n" + "void g()\n" + "{\n" + "int a = 2;\n" + "}\n"; + + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + + tokenizer.setVarId(); + tokenizer.simplifyTokenList(); + + std::ostringstream ostr; + for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS(std::string(" void f ( ) { const int a = 45 ; } void g ( ) { int a ; a = 2 ; }"), ostr.str()); + } }; REGISTER_TEST(TestTokenizer)