@@ -106,6 +106,8 @@ class TestSymbolDatabase: public TestFixture {
106106
107107 TEST_CASE (test_isVariableDeclarationCanHandleNull);
108108 TEST_CASE (test_isVariableDeclarationIdentifiesSimpleDeclaration);
109+ TEST_CASE (test_isVariableDeclarationIdentifiesInitialization);
110+ TEST_CASE (test_isVariableDeclarationIdentifiesCpp11Initialization);
109111 TEST_CASE (test_isVariableDeclarationIdentifiesScopedDeclaration);
110112 TEST_CASE (test_isVariableDeclarationIdentifiesStdDeclaration);
111113 TEST_CASE (test_isVariableDeclarationIdentifiesScopedStdDeclaration);
@@ -221,6 +223,7 @@ class TestSymbolDatabase: public TestFixture {
221223 TEST_CASE (symboldatabase41); // ticket #5197 (unknown macro)
222224 TEST_CASE (symboldatabase42); // only put variables in variable list
223225 TEST_CASE (symboldatabase43); // #4738
226+ TEST_CASE (symboldatabase44);
224227
225228 TEST_CASE (isImplicitlyVirtual);
226229
@@ -282,6 +285,34 @@ class TestSymbolDatabase: public TestFixture {
282285 ASSERT (false == v.isReference ());
283286 }
284287
288+ void test_isVariableDeclarationIdentifiesInitialization () {
289+ reset ();
290+ givenACodeSampleToTokenize simpleDeclaration (" int x (1);" );
291+ bool result = si.isVariableDeclaration (simpleDeclaration.tokens (), vartok, typetok);
292+ ASSERT_EQUALS (true , result);
293+ ASSERT_EQUALS (" x" , vartok->str ());
294+ ASSERT_EQUALS (" int" , typetok->str ());
295+ Variable v (vartok, typetok, vartok->previous (), 0 , Public, 0 , 0 );
296+ ASSERT (false == v.isArray ());
297+ ASSERT (false == v.isPointer ());
298+ ASSERT (false == v.isReference ());
299+ ASSERT (true == v.isIntegralType ());
300+ }
301+
302+ void test_isVariableDeclarationIdentifiesCpp11Initialization () {
303+ reset ();
304+ givenACodeSampleToTokenize simpleDeclaration (" int x {1};" );
305+ bool result = si.isVariableDeclaration (simpleDeclaration.tokens (), vartok, typetok);
306+ ASSERT_EQUALS (true , result);
307+ ASSERT_EQUALS (" x" , vartok->str ());
308+ ASSERT_EQUALS (" int" , typetok->str ());
309+ Variable v (vartok, typetok, vartok->previous (), 0 , Public, 0 , 0 );
310+ ASSERT (false == v.isArray ());
311+ ASSERT (false == v.isPointer ());
312+ ASSERT (false == v.isReference ());
313+ ASSERT (true == v.isIntegralType ());
314+ }
315+
285316 void test_isVariableDeclarationIdentifiesScopedDeclaration () {
286317 reset ();
287318 givenACodeSampleToTokenize ScopedDeclaration (" ::int x;" );
@@ -1879,6 +1910,20 @@ class TestSymbolDatabase: public TestFixture {
18791910 ASSERT_EQUALS (" " , errout.str ());
18801911 }
18811912
1913+ void symboldatabase44 () {
1914+ GET_SYMBOL_DB (" int i { 1 };\n "
1915+ " int j ( i );\n "
1916+ " void foo() {\n "
1917+ " int k { 1 };\n "
1918+ " int l ( 1 );\n "
1919+ " }" );
1920+ ASSERT (db != nullptr );
1921+ ASSERT_EQUALS (4U , db->getVariableListSize () - 1 );
1922+ ASSERT_EQUALS (2U , db->scopeList .size ());
1923+ for (std::size_t i = 1U ; i < db->getVariableListSize (); i++)
1924+ ASSERT (db->getVariableFromVarId (i) != nullptr );
1925+ }
1926+
18821927 void isImplicitlyVirtual () {
18831928 {
18841929 GET_SYMBOL_DB (" class Base {\n "
0 commit comments