Cleanup test/testtokenize.cpp a bit by putting duplicate code into a function.

This commit is contained in:
Reijo Tomperi 2010-02-25 22:00:39 +02:00
parent 377d3091a9
commit 23407c7f1d
1 changed files with 228 additions and 409 deletions

View File

@ -1177,25 +1177,32 @@ private:
} }
} }
std::string tokenizeDebugListing(const std::string &code, bool simplify = false)
{
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
if (simplify)
tokenizer.simplifyTokenList();
// result..
return tokenizer.tokens()->stringifyList(true);
}
void varid1() void varid1()
{ {
{ {
const std::string code("static int i = 1;\n" const std::string actual = tokenizeDebugListing(
"void f()\n" "static int i = 1;\n"
"{\n" "void f()\n"
" int i = 2;\n" "{\n"
" for (int i = 0; i < 10; ++i)\n" " int i = 2;\n"
" i = 3;\n" " for (int i = 0; i < 10; ++i)\n"
" i = 4;\n" " i = 3;\n"
"}\n"); " i = 4;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: static int i@1 = 1 ;\n" "1: static int i@1 = 1 ;\n"
"2: void f ( )\n" "2: void f ( )\n"
@ -1210,24 +1217,18 @@ private:
} }
{ {
const std::string code("static int i = 1;\n" const std::string actual = tokenizeDebugListing(
"void f()\n" "static int i = 1;\n"
"{\n" "void f()\n"
" int i = 2;\n" "{\n"
" for (int i = 0; i < 10; ++i)\n" " int i = 2;\n"
" {\n" " for (int i = 0; i < 10; ++i)\n"
" i = 3;\n" " {\n"
" }\n" " i = 3;\n"
" i = 4;\n" " }\n"
"}\n"); " i = 4;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: static int i@1 = 1 ;\n" "1: static int i@1 = 1 ;\n"
"2: void f ( )\n" "2: void f ( )\n"
@ -1246,20 +1247,14 @@ private:
void varid2() void varid2()
{ {
const std::string code("void f()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f()\n"
" struct ABC abc;\n" "{\n"
" abc.a = 3;\n" " struct ABC abc;\n"
" i = abc.a;\n" " abc.a = 3;\n"
"}\n"); " i = abc.a;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( )\n" "1: void f ( )\n"
"2: {\n" "2: {\n"
@ -1273,20 +1268,14 @@ private:
void varid3() void varid3()
{ {
const std::string code("static char str[4];\n" const std::string actual = tokenizeDebugListing(
"void f()\n" "static char str[4];\n"
"{\n" "void f()\n"
" char str[10];\n" "{\n"
" str[0] = 0;\n" " char str[10];\n"
"}\n"); " str[0] = 0;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: static char str@1 [ 4 ] ;\n" "1: static char str@1 [ 4 ] ;\n"
"2: void f ( )\n" "2: void f ( )\n"
@ -1300,19 +1289,12 @@ private:
void varid4() void varid4()
{ {
const std::string code("void f(const unsigned int a[])\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f(const unsigned int a[])\n"
" int i = *(a+10);\n" "{\n"
"}\n"); " int i = *(a+10);\n"
"}\n", true);
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( const int a@1 [ ] )\n" "1: void f ( const int a@1 [ ] )\n"
"2: {\n" "2: {\n"
@ -1324,19 +1306,12 @@ private:
void varid5() void varid5()
{ {
const std::string code("void f()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f()\n"
" int a,b;\n" "{\n"
"}\n"); " int a,b;\n"
"}\n", true);
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( )\n" "1: void f ( )\n"
"2: {\n" "2: {\n"
@ -1349,19 +1324,12 @@ private:
void varid6() void varid6()
{ {
const std::string code("int f(int a, int b)\n" const std::string actual = tokenizeDebugListing(
"{\n" "int f(int a, int b)\n"
" return a+b;\n" "{\n"
"}\n"); " return a+b;\n"
"}\n", true);
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: int f ( int a@1 , int b@2 )\n" "1: int f ( int a@1 , int b@2 )\n"
"2: {\n" "2: {\n"
@ -1374,21 +1342,15 @@ private:
void varid7() void varid7()
{ {
const std::string code("void func()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void func()\n"
"char a[256] = \"test\";\n" "{\n"
"{\n" "char a[256] = \"test\";\n"
"char b[256] = \"test\";\n" "{\n"
"}\n" "char b[256] = \"test\";\n"
"}\n"); "}\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void func ( )\n" "1: void func ( )\n"
"2: {\n" "2: {\n"
@ -1404,20 +1366,13 @@ private:
void varidReturn() void varidReturn()
{ {
const std::string code("int f()\n" const std::string actual = tokenizeDebugListing(
"{\n" "int f()\n"
" int a;\n" "{\n"
" return a;\n" " int a;\n"
"}\n"); " return a;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: int f ( )\n" "1: int f ( )\n"
"2: {\n" "2: {\n"
@ -1430,19 +1385,13 @@ private:
void varid8() void varid8()
{ {
const std::string code("void func()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void func()\n"
" std::string str(\"test\");\n" "{\n"
" str.clear();\n" " std::string str(\"test\");\n"
"}\n"); " str.clear();\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void func ( )\n" "1: void func ( )\n"
"2: {\n" "2: {\n"
@ -1455,15 +1404,9 @@ private:
void varid9() void varid9()
{ {
const std::string code("typedef int INT32;\n"); const std::string actual = tokenizeDebugListing(
"typedef int INT32;\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: ;\n"); "1: ;\n");
@ -1472,19 +1415,13 @@ private:
void varid10() void varid10()
{ {
const std::string code("void foo()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void foo()\n"
" int abc;\n" "{\n"
" struct abc abc1;\n" " int abc;\n"
"}"); " struct abc abc1;\n"
"}");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void foo ( )\n" "1: void foo ( )\n"
"2: {\n" "2: {\n"
@ -1497,15 +1434,9 @@ private:
void varid11() void varid11()
{ {
const std::string code("class Foo;\n"); const std::string actual = tokenizeDebugListing(
"class Foo;\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Foo ;\n"); "1: class Foo ;\n");
@ -1514,18 +1445,12 @@ private:
void varid12() void varid12()
{ {
const std::string code("static void a()\n" const std::string actual = tokenizeDebugListing(
"{\n" "static void a()\n"
" class Foo *foo;\n" "{\n"
"}\n"); " class Foo *foo;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: static void a ( )\n" "1: static void a ( )\n"
"2: {\n" "2: {\n"
@ -1537,20 +1462,13 @@ private:
void varid13() void varid13()
{ {
const std::string code("void f()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f()\n"
" int a; int b;\n" "{\n"
" a = a;\n" " int a; int b;\n"
"}\n"); " a = a;\n"
"}\n", true);
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( )\n" "1: void f ( )\n"
"2: {\n" "2: {\n"
@ -1564,20 +1482,14 @@ private:
void varid14() void varid14()
{ {
// Overloaded operator* // Overloaded operator*
const std::string code("void foo()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void foo()\n"
"A a;\n" "{\n"
"B b;\n" "A a;\n"
"b * a;\n" "B b;\n"
"}"); "b * a;\n"
"}");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void foo ( )\n" "1: void foo ( )\n"
"2: {\n" "2: {\n"
@ -1591,25 +1503,18 @@ private:
void varidStl() void varidStl()
{ {
const std::string code("list<int> ints;\n" const std::string actual = tokenizeDebugListing(
"list<int>::iterator it;\n" "list<int> ints;\n"
"std::vector<std::string> dirs;\n" "list<int>::iterator it;\n"
"std::map<int, int> coords;\n" "std::vector<std::string> dirs;\n"
"std::tr1::unordered_map<int, int> xy;\n" "std::map<int, int> coords;\n"
"std::list<boost::wave::token_id> tokens;\n" "std::tr1::unordered_map<int, int> xy;\n"
"static std::vector<CvsProcess*> ex1;\n" "std::list<boost::wave::token_id> tokens;\n"
"extern std::vector<CvsProcess*> ex2;\n" "static std::vector<CvsProcess*> ex1;\n"
"std::map<int, 1> m;\n" "extern std::vector<CvsProcess*> ex2;\n"
); "std::map<int, 1> m;\n"
);
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: list < int > ints@1 ;\n" "1: list < int > ints@1 ;\n"
"2: list < int > :: iterator it@2 ;\n" "2: list < int > :: iterator it@2 ;\n"
@ -1627,20 +1532,13 @@ private:
void varid_delete() void varid_delete()
{ {
const std::string code("void f()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f()\n"
" int *a;\n" "{\n"
" delete a;\n" " int *a;\n"
"}\n"); " delete a;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( )\n" "1: void f ( )\n"
"2: {\n" "2: {\n"
@ -1654,17 +1552,10 @@ private:
void varid_functions() void varid_functions()
{ {
{ {
const std::string code("void f();\n" const std::string actual = tokenizeDebugListing(
"void f(){}\n"); "void f();\n"
"void f(){}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( ) ;\n" "1: void f ( ) ;\n"
"2: void f ( ) { }\n"); "2: void f ( ) { }\n");
@ -1673,19 +1564,12 @@ private:
} }
{ {
const std::string code("A f(3);\n" const std::string actual = tokenizeDebugListing(
"A f2(true);\n" "A f(3);\n"
"A g();\n" "A f2(true);\n"
"A e(int c);\n"); "A g();\n"
"A e(int c);\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: A f@1 ( 3 ) ;\n" "1: A f@1 ( 3 ) ;\n"
"2: A f2@2 ( true ) ;\n" "2: A f2@2 ( true ) ;\n"
@ -1696,27 +1580,20 @@ private:
} }
{ {
const std::string code("void f1(int &p)\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f1(int &p)\n"
" p = 0;\n" "{\n"
"}\n" " p = 0;\n"
"void f2(std::string &str)\n" "}\n"
"{\n" "void f2(std::string &str)\n"
" str.clear();\n" "{\n"
"}\n" " str.clear();\n"
"void f3(const std::string &s)\n" "}\n"
"{\n" "void f3(const std::string &s)\n"
" s.size();\n" "{\n"
"}\n"); " s.size();\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f1 ( int & p@1 )\n" "1: void f1 ( int & p@1 )\n"
"2: {\n" "2: {\n"
@ -1738,21 +1615,14 @@ private:
void varid_reference_to_containers() void varid_reference_to_containers()
{ {
const std::string code("void f()\n" const std::string actual = tokenizeDebugListing(
"{\n" "void f()\n"
" std::vector<int> b;\n" "{\n"
" std::vector<int> &a = b;\n" " std::vector<int> b;\n"
" std::vector<int> *c = &b;\n" " std::vector<int> &a = b;\n"
"}\n"); " std::vector<int> *c = &b;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: void f ( )\n" "1: void f ( )\n"
"2: {\n" "2: {\n"
@ -1766,21 +1636,14 @@ private:
void varid_in_class() void varid_in_class()
{ {
const std::string code("class Foo\n" const std::string actual = tokenizeDebugListing(
"{\n" "class Foo\n"
"public:\n" "{\n"
" std::string name1;\n" "public:\n"
" std::string name2;\n" " std::string name1;\n"
"};\n"); " std::string name2;\n"
"};\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Foo\n" "1: class Foo\n"
"2: {\n" "2: {\n"
@ -1794,20 +1657,13 @@ private:
void varid_operator() void varid_operator()
{ {
const std::string code("class Foo\n" const std::string actual = tokenizeDebugListing(
"{\n" "class Foo\n"
"public:\n" "{\n"
" void operator=(const Foo &);\n" "public:\n"
"};\n"); " void operator=(const Foo &);\n"
"};\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Foo\n" "1: class Foo\n"
"2: {\n" "2: {\n"
@ -1820,31 +1676,24 @@ private:
void varidclass1() void varidclass1()
{ {
const std::string code("class Fred\n" const std::string actual = tokenizeDebugListing(
"{\n" "class Fred\n"
"private:\n" "{\n"
" int i;\n" "private:\n"
"\n" " int i;\n"
" void foo1();\n" "\n"
" void foo2()\n" " void foo1();\n"
" {\n" " void foo2()\n"
" ++i;\n" " {\n"
" }\n" " ++i;\n"
"}\n" " }\n"
"\n" "}\n"
"Fred::foo1()\n" "\n"
"{\n" "Fred::foo1()\n"
" i = 0;\n" "{\n"
"}\n"); " i = 0;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Fred\n" "1: class Fred\n"
"2: {\n" "2: {\n"
@ -1869,27 +1718,20 @@ private:
void varidclass2() void varidclass2()
{ {
const std::string code("class Fred\n" const std::string actual = tokenizeDebugListing(
"{ void f(); };\n" "class Fred\n"
"\n" "{ void f(); };\n"
"void A::foo1()\n" "\n"
"{\n" "void A::foo1()\n"
" int i = 0;\n" "{\n"
"}\n" " int i = 0;\n"
"\n" "}\n"
"void Fred::f()\n" "\n"
"{\n" "void Fred::f()\n"
" i = 0;\n" "{\n"
"}\n"); " i = 0;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Fred\n" "1: class Fred\n"
"2: { void f ( ) ; } ;\n" "2: { void f ( ) ; } ;\n"
@ -1910,27 +1752,20 @@ private:
void varidclass3() void varidclass3()
{ {
const std::string code("class Fred\n" const std::string actual = tokenizeDebugListing(
"{ int i; void f(); };\n" "class Fred\n"
"\n" "{ int i; void f(); };\n"
"void Fred::f()\n" "\n"
"{\n" "void Fred::f()\n"
" i = 0;\n" "{\n"
"}\n" " i = 0;\n"
"\n" "}\n"
"void A::f()\n" "\n"
"{\n" "void A::f()\n"
" i = 0;\n" "{\n"
"}\n"); " i = 0;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Fred\n" "1: class Fred\n"
"2: { int i@1 ; void f ( ) ; } ;\n" "2: { int i@1 ; void f ( ) ; } ;\n"
@ -1951,23 +1786,16 @@ private:
void varidclass4() void varidclass4()
{ {
const std::string code("class Fred\n" const std::string actual = tokenizeDebugListing(
"{ int i; void f(); };\n" "class Fred\n"
"\n" "{ int i; void f(); };\n"
"void Fred::f()\n" "\n"
"{\n" "void Fred::f()\n"
" if (i) { }\n" "{\n"
" i = 0;\n" " if (i) { }\n"
"}\n"); " i = 0;\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class Fred\n" "1: class Fred\n"
"2: { int i@1 ; void f ( ) ; } ;\n" "2: { int i@1 ; void f ( ) ; } ;\n"
@ -1983,22 +1811,15 @@ private:
void varidclass5() void varidclass5()
{ {
const std::string code("class A { };\n" const std::string actual = tokenizeDebugListing(
"class B\n" "class A { };\n"
"{\n" "class B\n"
" A *a;\n" "{\n"
" B() : a(new A)\n" " A *a;\n"
" { }\n" " B() : a(new A)\n"
"};\n"); " { }\n"
"};\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n\n##file 0\n" const std::string expected("\n\n##file 0\n"
"1: class A { } ;\n" "1: class A { } ;\n"
"2: class B\n" "2: class B\n"
@ -2011,8 +1832,6 @@ private:
ASSERT_EQUALS(expected, actual); ASSERT_EQUALS(expected, actual);
} }
void file1() void file1()
{ {
const char code[] = "a1\n" const char code[] = "a1\n"