diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index efe54bcfd..6de413d10 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -84,6 +84,7 @@ private: TEST_CASE(template4); TEST_CASE(template5); TEST_CASE(template6); + TEST_CASE(template7); TEST_CASE(namespaces); @@ -576,6 +577,86 @@ private: ASSERT_EQUALS(expected, sizeof_(code)); } + void template7() + { + // Typedef + { + const char code[] = "template \n" + "class ABC\n" + "{\n" + "public:\n" + " typedef ABC m;\n" + "\n" + "};\n" + "\n" + "int main()\n" + "{}\n"; + + const std::string expected(" template < class T > " + "class ABC " + "{ " + "public: " + "typedef ABC m ; " + "} ; " + "int main ( )" + " { }"); + + TODO_ASSERT_EQUALS(expected, sizeof_(code)); + } + + { + const char code[] = "template class ABC {\n" + "public:\n" + " typedef std::vector type;\n" + "};\n" + "int main() {\n" + " ABC::type v;\n" + " v.push_back(4);\n" + " return 0;\n" + "}\n"; + + const std::string expected(" template < typename T > class ABC {" + " public: " + "typedef std :: vector < T > type ; " + "} ; " + "int main ( ) { " + "std :: vector < int > v ; " + "v . push_back ( 4 ) ; " + "return 0 ; " + "}"); + + TODO_ASSERT_EQUALS(expected, sizeof_(code)); + } + + { + const char code[] = "template class ABC {\n" + "public:\n" + " typedef std::vector type;\n" + " void f()\n" + " {\n" + " ABC::type v;\n" + " v.push_back(4);\n" + " }\n" + "};\n" + "\n" + "int main() {\n" + " return 0;\n" + "}"; + + const std::string expected(" template < typename T > class ABC " + "{" + " public: typedef std :: vector < T > type ;" + " void f ( ) " + "{ " + "std :: vector < int > v ;" + " v . push_back ( 4 ) ;" + " } " + "} ; " + "int main ( ) { return 0 ; }"); + + TODO_ASSERT_EQUALS(expected, sizeof_(code)); + } + } void namespaces() {