From e098bffd28bb94a8fa2cda4ab27b0f6627f671fb Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Tue, 5 May 2009 23:09:15 +0300 Subject: [PATCH] Added test case TestSimplifyTokens::template7 --- test/testsimplifytokens.cpp | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) 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() {