diff --git a/test/testclass.cpp b/test/testclass.cpp index 61b4aadbc..6602901a3 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -46,6 +46,7 @@ private: TEST_CASE(uninitVar1); TEST_CASE(uninitVarStream); TEST_CASE(privateCtor); // If constructor is private.. + // TODO TEST_CASE(function); // Function is not variable } // Check that base classes have virtual destructors @@ -189,10 +190,29 @@ private: "};\n"); ASSERT_EQUALS(std::string(""), errout.str()); - } + void function() + { + checkUninitVar("class A\n" + "{\n" + "public:\n" + " A();\n" + " int* f(int*);\n" + "};\n" + "\n" + "A::A()\n" + "{\n" + "}\n" + "\n" + "int* A::f(int* p)\n" + "{\n" + " return p;\n" + "}\n"); + + ASSERT_EQUALS(std::string(""), errout.str()); + } }; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 89422beb3..9341c554b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -76,7 +76,8 @@ private: TEST_CASE(simplify_function_parameters); - TEST_CASE(reduce_redundant_paranthesis); // Ticket #61 + TEST_CASE(reduce_redundant_paranthesis1); // Ticket #61 + TEST_CASE(reduce_redundant_paranthesis2); // Ticket #61 TEST_CASE(sizeof1); TEST_CASE(sizeof2); @@ -809,7 +810,7 @@ private: // Simplify "((..))" into "(..)" - void reduce_redundant_paranthesis() + void reduce_redundant_paranthesis1() { const char code[] = "void foo()\n" "{\n" @@ -829,6 +830,29 @@ private: ASSERT_EQUALS(std::string(" void foo ( ) { free ( p ) ; }"), ostr.str()); } + // Simplify "((..))" into "(..)" + void reduce_redundant_paranthesis2() + { + const char code[] = "class A\n" + "{\n" + "public:\n" + " A();\n" + " int *p(int *);\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(" class A { public: A ( ) ; int * p ( int * ) ; }"), ostr.str()); + } + void sizeof1()