diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index ad3703a04..cc381901c 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -461,8 +461,7 @@ private: const char code[] = "class BB {};\n" "\n" "template \n" - "class AA\n" - "{\n" + "class AA {\n" "public:\n" " static AA create(T* newObject);\n" " static int size();\n" @@ -481,9 +480,30 @@ private: " {}\n" "\n" "int yy[AA::size()];"; - - // Just run it and check that there are not assertions. - tok(code); + const char expected[] = "class BB { } ; " + "class AA ; " + "class AA ; " + "class CC { public: CC ( AA , int ) { } } ; " + "class XX { " + "AA y ; " + "public: " + "XX ( ) ; " + "} ; " + "XX :: XX ( ) : " + "y ( AA :: create ( new CC ( AA ( ) , 0 ) ) ) " + "{ } " + "int yy [ AA :: size ( ) ] ; " + "class AA { " + "public: " + "static AA create ( BB * newObject ) ; " + "static int size ( ) ; " + "} ; " + "class AA { " + "public: " + "static AA create ( CC * newObject ) ; " + "static int size ( ) ; " + "} ;"; + ASSERT_EQUALS(expected, tok(code)); } void template14() { @@ -494,14 +514,11 @@ private: "{\n" "foo();\n" "}\n"; - - // The expected result.. const char expected[] = "void foo ( ) ; " "void foo ( ) " "{ x ( ) ; } " "int main ( ) " "{ foo ( ) ; }"; - ASSERT_EQUALS(expected, tok(code)); } @@ -582,9 +599,16 @@ private: "};\n" "\n" "shared_ptr i;\n"; - - // Assert that there is no segmentation fault.. - tok(code); + const char expected[] = "template < class T > " + "class Fred " + "{ " + "template < class T > " + "static shared_ptr < Fred < T > > CreateFred ( ) " + "{ " + "} " + "} ; " + "shared_ptr < int > i ;"; + ASSERT_EQUALS(expected, tok(code)); } void template18() { @@ -919,7 +943,23 @@ private: " A> gna1;\n" " A gna2;\n" "}\n"; - tok(code); // Don't crash or freeze + const char expected[] = "class A> ; " + "class A ; " + "int main ( ) { " + "A> gna1 ; " + "A gna2 ; " + "} " + "class A> { " + "A mT ; " + "public: " + "void foo ( ) { } " + "} ; " + "class A { " + "BLA mT ; " + "public: " + "void foo ( ) { } " + "} ;"; + ASSERT_EQUALS(expected, tok(code)); } void template39() { // #4742 - Used to freeze in 1.60 @@ -981,14 +1021,25 @@ private: } void template44() { // #5297 - tok("template struct StackContainer {" - " void foo(int i) {" - " if (0 >= 1 && i<0) {}" - " }" - "};" - "template class ZContainer : public StackContainer {};" - "struct FGSTensor {};" - "class FoldedZContainer : public ZContainer {};"); + const char code[] = "template struct StackContainer {" + " void foo(int i) {" + " if (0 >= 1 && i<0) {}" + " }" + "};" + "template class ZContainer : public StackContainer {};" + "struct FGSTensor {};" + "class FoldedZContainer : public ZContainer {};"; + const char expected[] = "struct StackContainer ; " + "class ZContainer ; " + "struct FGSTensor { } ; " + "class FoldedZContainer : public ZContainer { } ; " + "class ZContainer : public StackContainer { } ; " + "struct StackContainer { " + "void foo ( int i ) { " + "if ( 0 >= 1 && i < 0 ) { } " + "} " + "} ;"; + ASSERT_EQUALS(expected, tok(code, false)); } void template45() { // #5814 @@ -1081,13 +1132,31 @@ private: } void template52() { // #6437 - tok("template int sum() { " - " return value + sum(); " - "} " - "template int calculate_value() { " - " return sum(); " - "} " - "int value = calculate_value<1,1>();"); + const char code[] = "template int sum() { " + " return value + sum(); " + "} " + "template int calculate_value() { " + " if (x != y) { " + " return sum(); " + " } else { " + " return 0; " + " } " + "} " + "int value = calculate_value<1,1>();"; + const char expected[] = "int sum<0> ( ) ; " + "int calculate_value<1,1> ( ) ; " + "int value ; value = calculate_value<1,1> ( ) ; " + "int calculate_value<1,1> ( ) { " + "if ( 1 != 1 ) { " + "return sum<0> ( ) ; " + "} else { " + "return 0 ; " + "} " + "} " + "int sum<0> ( ) { " + "return 0 + sum<0> ( ) ; " + "}"; + ASSERT_EQUALS(expected, tok(code, false)); } void template53() { // #4335