From 67f30376e11fb424d12d3069121f1825e536a90c Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 24 Jan 2009 07:56:47 +0000 Subject: [PATCH] Added test case simplify_function_parameters --- test/testtokenize.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3256c0d0a..b8ecc1bd5 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -72,6 +72,8 @@ private: TEST_CASE(file2); TEST_CASE(doublesharp); + + // TODO TEST_CASE(simplify_function_parameters); } @@ -709,6 +711,45 @@ private: ASSERT_EQUALS("TEST ( var , val ) var ## _ ## val = val ", ostr.str()); } + + void simplify_function_parameters() + { + { + const char code[] = "void f(x) int x;\n" + "{\n" + "}\n"; + + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + + tokenizer.simplifyTokenList(); + + std::ostringstream ostr; + for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS(std::string(" void f ( int x ) { }"), ostr.str()); + } + + { + const char code[] = "void f(x,y) int x; char y;\n" + "{\n" + "}\n"; + + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + + tokenizer.simplifyTokenList(); + + std::ostringstream ostr; + for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS(std::string(" void f ( int x, char y ) { }"), ostr.str()); + } + } }; REGISTER_TEST(TestTokenizer)