aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testprimitivetypetag.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-07 16:18:58 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:04 -0300
commit644d7b74d18a5838a7f26de02bd0aa9a212de85c (patch)
treeed946d547d5dc0a6e6893ab22efb412d0ab35716 /tests/testprimitivetypetag.cpp
parent99d400c0ca0f139714448bc8ab3796495d8b316d (diff)
Added the "default-constructor" attribute to the "primitive-type" tag.
The default-constructor attribute specifies a way to build an instance of a class declared as primitive type using default arguments. Documentation and a test were also added. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests/testprimitivetypetag.cpp')
-rw-r--r--tests/testprimitivetypetag.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/testprimitivetypetag.cpp b/tests/testprimitivetypetag.cpp
new file mode 100644
index 000000000..ebd245bf9
--- /dev/null
+++ b/tests/testprimitivetypetag.cpp
@@ -0,0 +1,55 @@
+/*
+* This file is part of the API Extractor project.
+*
+* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+*
+* Contact: PySide team <contact@pyside.org>
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+#include "testprimitivetypetag.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+
+void TestPrimitiveTypeTag::testPrimitiveTypeDefaultConstructor()
+{
+ const char* cppCode ="\
+ struct A {};\
+ struct B {};\
+ ";
+ const char* xmlCode = "\
+ <typesystem package=\"Foo\"> \
+ <primitive-type name='A' default-constructor='A()'/> \
+ <object-type name='B' /> \
+ </typesystem>";
+ TestUtil t(cppCode, xmlCode, false);
+
+ AbstractMetaClassList classes = t.builder()->classes();
+ QCOMPARE(classes.count(), 1);
+ AbstractMetaClass* classB = classes.findClass("B");
+ QVERIFY(classB);
+
+ PrimitiveTypeEntry* typeEntry = TypeDatabase::instance()->findPrimitiveType("A");
+ QVERIFY(typeEntry);
+ QVERIFY(typeEntry->hasDefaultConstructor());
+ QCOMPARE(typeEntry->defaultConstructor(), QString("A()"));
+}
+
+QTEST_APPLESS_MAIN(TestPrimitiveTypeTag)
+
+#include "testprimitivetypetag.moc"
+