@@ -277,10 +277,10 @@ class TestSimplifyTypedef : public TestFixture {
277277 return tokenizer.tokens ()->stringifyList (nullptr , !options.simplify );
278278 }
279279
280- std::string simplifyTypedef (const char code[]) {
280+ template <size_t size>
281+ std::string simplifyTypedef (const char (&data)[size]) {
281282 TokenList tokenlist{settings1, Standards::Language::CPP};
282- std::istringstream istr (code);
283- if (!tokenlist.createTokens (istr))
283+ if (!tokenlist.createTokens (data, size-1 ))
284284 return " " ;
285285 Tokenizer tokenizer (std::move (tokenlist), *this );
286286 tokenizer.createLinks ();
@@ -311,11 +311,11 @@ class TestSimplifyTypedef : public TestFixture {
311311 }
312312
313313
314- std::string simplifyTypedefC (const char code[]) {
314+ template <size_t size>
315+ std::string simplifyTypedefC (const char (&data)[size]) {
315316 TokenList tokenlist{settings1, Standards::Language::C};
316317
317- std::istringstream istr (code);
318- if (!TokenListHelper::createTokens (tokenlist, istr, " file.c" ))
318+ if (!TokenListHelper::createTokens (tokenlist, data, size-1 , " file.c" ))
319319 return " " ;
320320 Tokenizer tokenizer (std::move (tokenlist), *this );
321321 tokenizer.createLinks ();
@@ -328,10 +328,10 @@ class TestSimplifyTypedef : public TestFixture {
328328 return tokenizer.tokens ()->stringifyList (nullptr , false );
329329 }
330330
331- std::string dumpTypedefInfo (const char code[]) {
331+ template <size_t size>
332+ std::string dumpTypedefInfo (const char (&code)[size]) {
332333 TokenList tokenlist{settings1, Standards::Language::C};
333- std::istringstream istr (code);
334- if (!TokenListHelper::createTokens (tokenlist, istr, " file.c" ))
334+ if (!TokenListHelper::createTokens (tokenlist, code, " file.c" ))
335335 return {};
336336 Tokenizer tokenizer (std::move (tokenlist), *this );
337337 tokenizer.createLinks ();
@@ -515,17 +515,16 @@ class TestSimplifyTypedef : public TestFixture {
515515 }
516516
517517 void carray3 () {
518- const char * code{};
519- code = " typedef int a[256];\n " // #11689
520- " typedef a b[256];\n "
521- " b* p;\n " ;
518+ const char code[] = " typedef int a[256];\n " // #11689
519+ " typedef a b[256];\n "
520+ " b* p;\n " ;
522521 ASSERT_EQUALS (" int ( * p ) [ 256 ] [ 256 ] ;" , simplifyTypedef (code));
523522
524- code = " typedef int a[1];\n "
525- " typedef a b[2];\n "
526- " typedef b c[3];\n "
527- " c* p;\n " ;
528- ASSERT_EQUALS (" int ( * p ) [ 3 ] [ 2 ] [ 1 ] ;" , simplifyTypedef (code ));
523+ const char code1[] = " typedef int a[1];\n "
524+ " typedef a b[2];\n "
525+ " typedef b c[3];\n "
526+ " c* p;\n " ;
527+ ASSERT_EQUALS (" int ( * p ) [ 3 ] [ 2 ] [ 1 ] ;" , simplifyTypedef (code1 ));
529528 }
530529
531530 void carray4 () {
@@ -4459,8 +4458,7 @@ class TestSimplifyTypedef : public TestFixture {
44594458 " void test(rFunctionPointer_fp functionPointer);" ;
44604459
44614460 TokenList tokenlist{settings1, Standards::Language::C};
4462- std::istringstream istr (code);
4463- ASSERT (TokenListHelper::createTokens (tokenlist, istr, " file.c" ));
4461+ ASSERT (TokenListHelper::createTokens (tokenlist, code, " file.c" ));
44644462 Tokenizer tokenizer (std::move (tokenlist), *this );
44654463 tokenizer.createLinks ();
44664464 tokenizer.simplifyTypedef ();
@@ -4502,8 +4500,7 @@ class TestSimplifyTypedef : public TestFixture {
45024500 " }" ;
45034501
45044502 TokenList tokenlist{settings1, Standards::Language::C};
4505- std::istringstream istr (code);
4506- ASSERT (TokenListHelper::createTokens (tokenlist, istr, " file.c" ));
4503+ ASSERT (TokenListHelper::createTokens (tokenlist, code, " file.c" ));
45074504 Tokenizer tokenizer (std::move (tokenlist), *this );
45084505 tokenizer.createLinks ();
45094506 tokenizer.simplifyTypedef ();
@@ -4521,8 +4518,7 @@ class TestSimplifyTypedef : public TestFixture {
45214518 " }" ;
45224519
45234520 TokenList tokenlist{settings1, Standards::Language::C};
4524- std::istringstream istr (code);
4525- ASSERT (TokenListHelper::createTokens (tokenlist, istr, " file.c" ));
4521+ ASSERT (TokenListHelper::createTokens (tokenlist, code, " file.c" ));
45264522 Tokenizer tokenizer (std::move (tokenlist), *this );
45274523 tokenizer.createLinks ();
45284524 tokenizer.simplifyTypedef ();
0 commit comments