From 15b355dca205090adf9fe338f02963f945263d98 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 15 Aug 2011 16:20:39 -0300 Subject: Included the unsigned types in TypeEntry::isCppPrimitive() method list of types. Also added a test for a typedef of an unsigned numerical type. --- tests/testnumericaltypedef.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/testnumericaltypedef.cpp') diff --git a/tests/testnumericaltypedef.cpp b/tests/testnumericaltypedef.cpp index c479b8d69..e48796726 100644 --- a/tests/testnumericaltypedef.cpp +++ b/tests/testnumericaltypedef.cpp @@ -66,6 +66,48 @@ void TestNumericalTypedef::testNumericalTypedef() QVERIFY(realType->typeEntry()->isCppPrimitive()); } +void TestNumericalTypedef::testUnsignedNumericalTypedef() +{ + const char* cppCode ="\ + typedef unsigned short ushort;\ + void funcUnsignedShort(unsigned short);\ + void funcUShort(ushort);\ + "; + const char* xmlCode = "\ + \ + \ + \ + \ + \ + \ + "; + TestUtil t(cppCode, xmlCode, false); + + QCOMPARE(t.builder()->globalFunctions().size(), 2); + const AbstractMetaFunction* funcUnsignedShort = t.builder()->globalFunctions().first(); + QVERIFY(funcUnsignedShort); + const AbstractMetaFunction* funcUShort = t.builder()->globalFunctions().last(); + QVERIFY(funcUShort); + + if (funcUnsignedShort->name() == "funcUShort") + std::swap(funcUnsignedShort, funcUShort); + + QCOMPARE(funcUnsignedShort->minimalSignature(), QString("funcUnsignedShort(unsigned short)")); + QCOMPARE(funcUShort->minimalSignature(), QString("funcUShort(ushort)")); + + const AbstractMetaType* unsignedShortType = funcUnsignedShort->arguments().first()->type(); + QVERIFY(unsignedShortType); + QCOMPARE(unsignedShortType->cppSignature(), QString("unsigned short")); + QVERIFY(unsignedShortType->isPrimitive()); + QVERIFY(unsignedShortType->typeEntry()->isCppPrimitive()); + + const AbstractMetaType* ushortType = funcUShort->arguments().first()->type(); + QVERIFY(ushortType); + QCOMPARE(ushortType->cppSignature(), QString("ushort")); + QVERIFY(ushortType->isPrimitive()); + QVERIFY(ushortType->typeEntry()->isCppPrimitive()); +} + QTEST_APPLESS_MAIN(TestNumericalTypedef) #include "testnumericaltypedef.moc" -- cgit v1.2.3