@@ -242,6 +242,10 @@ class TestSymbolDatabase: public TestFixture {
242242 TEST_CASE (symboldatabase53); // #7124 (library podtype)
243243 TEST_CASE (symboldatabase54); // #7257
244244
245+ TEST_CASE (enum1);
246+ TEST_CASE (enum2);
247+ TEST_CASE (enum3);
248+
245249 TEST_CASE (isImplicitlyVirtual);
246250 TEST_CASE (isPure);
247251
@@ -2251,6 +2255,44 @@ class TestSymbolDatabase: public TestFixture {
22512255 }
22522256 }
22532257
2258+ void enum1 () {
2259+ GET_SYMBOL_DB (" enum BOOL { FALSE, TRUE }; enum BOOL b;" );
2260+
2261+ /* there is a enum scope with the name BOOL */
2262+ ASSERT (db && db->scopeList .back ().type == Scope::eEnum && db->scopeList .back ().className == " BOOL" );
2263+
2264+ /* b is a enum variable, type is BOOL */
2265+ ASSERT (db && db->getVariableFromVarId (1 )->isEnumType ());
2266+ }
2267+
2268+ void enum2 () {
2269+ GET_SYMBOL_DB (" enum BOOL { FALSE, TRUE } b;" );
2270+
2271+ /* there is a enum scope with the name BOOL */
2272+ ASSERT (db && db->scopeList .back ().type == Scope::eEnum && db->scopeList .back ().className == " BOOL" );
2273+
2274+ /* b is a enum variable, type is BOOL */
2275+ ASSERT (db && db->getVariableFromVarId (1 )->isEnumType ());
2276+ }
2277+
2278+ void enum3 () {
2279+ GET_SYMBOL_DB (" enum ABC { A=11,B,C=A+B };" );
2280+ ASSERT (db && db->scopeList .back ().type == Scope::eEnum);
2281+ if (db) {
2282+ /* There is an enum A with value 11 */
2283+ const Enumerator *A = db->scopeList .back ().findEnumerator (" A" );
2284+ ASSERT (A && A->value ==11 && A->value_known );
2285+
2286+ /* There is an enum B with value 12 */
2287+ const Enumerator *B = db->scopeList .back ().findEnumerator (" B" );
2288+ ASSERT (B && B->value ==12 && B->value_known );
2289+
2290+ /* There is an enum C with value 23 */
2291+ const Enumerator *C = db->scopeList .back ().findEnumerator (" C" );
2292+ ASSERT (C && C->value ==23 && C->value_known );
2293+ }
2294+ }
2295+
22542296 void isImplicitlyVirtual () {
22552297 {
22562298 GET_SYMBOL_DB (" class Base {\n "
0 commit comments