aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-15 16:20:39 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:18 -0300
commit15b355dca205090adf9fe338f02963f945263d98 (patch)
tree5442a17d63b101adb908faa9295690d626f6d7a2 /tests
parent26eeabae2ac5f8b449d34bf472b1e506efdf35cd (diff)
Included the unsigned types in TypeEntry::isCppPrimitive() method list of types.
Also added a test for a typedef of an unsigned numerical type.
Diffstat (limited to 'tests')
-rw-r--r--tests/testnumericaltypedef.cpp42
-rw-r--r--tests/testnumericaltypedef.h1
2 files changed, 43 insertions, 0 deletions
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 = "\
+ <typesystem package='Foo'> \
+ <primitive-type name='short' /> \
+ <primitive-type name='unsigned short' /> \
+ <primitive-type name='ushort' /> \
+ <function signature='funcUnsignedShort(unsigned short)' />\
+ <function signature='funcUShort(ushort)' />\
+ </typesystem>";
+ 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"
diff --git a/tests/testnumericaltypedef.h b/tests/testnumericaltypedef.h
index ee11e63e2..a1d1bbe59 100644
--- a/tests/testnumericaltypedef.h
+++ b/tests/testnumericaltypedef.h
@@ -31,6 +31,7 @@ class TestNumericalTypedef : public QObject
Q_OBJECT
private slots:
void testNumericalTypedef();
+ void testUnsignedNumericalTypedef();
};
#endif