aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-09-30 10:50:04 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:11 -0300
commitf1987763b81d4a73063ebbd494dd3d09fef6383d (patch)
tree56a2809442f697abeb5ec2b1f922ff1c7922a9b6 /tests
parent7c1048b86bc76e68f728e4819fe832d17276bfe6 (diff)
Private enums are now accepted in the type system database.
This is done to allow enum value evaluation. Comes together with a nice test.
Diffstat (limited to 'tests')
-rw-r--r--tests/testenum.cpp43
-rw-r--r--tests/testenum.h1
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/testenum.cpp b/tests/testenum.cpp
index 17636badd..698efa8d6 100644
--- a/tests/testenum.cpp
+++ b/tests/testenum.cpp
@@ -255,6 +255,49 @@ void TestEnum::testEnumValueFromNeighbourEnum()
QCOMPARE(enumValueB1->stringValue(), QString("ValueA0"));
}
+void TestEnum::testPrivateEnum()
+{
+ const char* cppCode ="\
+ class A {\
+ private:\
+ enum PrivateEnum { Priv0 = 0x0f, Priv1 = 0xf0 };\
+ public:\
+ enum PublicEnum { Pub0 = Priv0, Pub1 = A::Priv1 };\
+ };\
+ ";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\"> \
+ <value-type name='A'> \
+ <enum-type name='PublicEnum'/>\
+ </value-type> \
+ </typesystem>";
+
+ TestUtil t(cppCode, xmlCode, false);
+
+ AbstractMetaClass* classA = t.builder()->classes().findClass("A");
+ QVERIFY(classA);
+ QCOMPARE(classA->enums().count(), 2);
+
+ AbstractMetaEnum* privateEnum = classA->findEnum("PrivateEnum");
+ QVERIFY(privateEnum);
+ QVERIFY(privateEnum->isPrivate());
+ QCOMPARE(privateEnum->typeEntry()->qualifiedCppName(), QString("A::PrivateEnum"));
+
+ AbstractMetaEnum* publicEnum = classA->findEnum("PublicEnum");
+ QVERIFY(publicEnum);
+ QCOMPARE(publicEnum->typeEntry()->qualifiedCppName(), QString("A::PublicEnum"));
+
+ AbstractMetaEnumValue* pub0 = publicEnum->values().first();
+ QCOMPARE(pub0->name(), QString("Pub0"));
+ QCOMPARE(pub0->value(), 0x0f);
+ QCOMPARE(pub0->stringValue(), QString("Priv0"));
+
+ AbstractMetaEnumValue* pub1 = publicEnum->values().last();
+ QCOMPARE(pub1->name(), QString("Pub1"));
+ QCOMPARE(pub1->value(), 0xf0);
+ QCOMPARE(pub1->stringValue(), QString("A::Priv1"));
+}
+
QTEST_APPLESS_MAIN(TestEnum)
#include "testenum.moc"
diff --git a/tests/testenum.h b/tests/testenum.h
index 762aed609..e4aaa1368 100644
--- a/tests/testenum.h
+++ b/tests/testenum.h
@@ -34,6 +34,7 @@ private slots:
void testAnonymousEnum();
void testGlobalEnums();
void testEnumValueFromNeighbourEnum();
+ void testPrivateEnum();
};
#endif