aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-07-05 19:11:04 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:17 -0300
commit2cc6e2afa7b9845ccfc62b9dce72b498034e8de9 (patch)
treeae6f0d89c25cd95233010dfab80f3af74bf79de4 /tests
parent31df158c68385c300f6c9b7cb0fe06bb3a789300 (diff)
Added revision attribute to type entries tags and flags-revision to enum-type tag.
These attributes will be useful to separate the wrapped API in revisions and ease the task of producing ABI compatible bindings.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/testtyperevision.cpp64
-rw-r--r--tests/testtyperevision.h36
3 files changed, 101 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5d991e68b..02537dea9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -41,6 +41,7 @@ declare_test(testreverseoperators)
declare_test(testtemplates)
declare_test(testtoposort)
declare_test(testvoidarg)
+declare_test(testtyperevision)
if (NOT DISABLE_DOCSTRINGS)
declare_test(testmodifydocumentation)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/a.xml"
diff --git a/tests/testtyperevision.cpp b/tests/testtyperevision.cpp
new file mode 100644
index 000000000..6fadfa9fa
--- /dev/null
+++ b/tests/testtyperevision.cpp
@@ -0,0 +1,64 @@
+/*
+* This file is part of the API Extractor project.
+*
+* Copyright (C) 2011 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 "testtyperevision.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+
+
+void TestTypeRevision::testRevisionAttr()
+{
+ const char* cppCode = "class Rev_0 {};"
+ "class Rev_1 {};"
+ "class Rev_2 { public: enum Rev_3 { X }; enum Rev_5 { Y }; };";
+ const char* xmlCode = "<typesystem package=\"Foo\">"
+ "<value-type name=\"Rev_0\"/>"
+ "<value-type name=\"Rev_1\" revision=\"1\"/>"
+ "<object-type name=\"Rev_2\" revision=\"2\">"
+ " <enum-type name=\"Rev_3\" revision=\"3\" flags=\"Flag_4\" flags-revision=\"4\" />"
+ " <enum-type name=\"Rev_5\" revision=\"5\" flags=\"Flag_5\" />"
+ "</object-type>"
+ "</typesystem>";
+ TestUtil t(cppCode, xmlCode);
+ AbstractMetaClassList classes = t.builder()->classes();
+ AbstractMetaClass* rev0 = classes.findClass("Rev_0");
+ QCOMPARE(getTypeRevision(rev0->typeEntry()), 0);
+
+ AbstractMetaClass* rev1 = classes.findClass("Rev_1");
+ QCOMPARE(getTypeRevision(rev1->typeEntry()), 1);
+
+ AbstractMetaClass* rev2 = classes.findClass("Rev_2");
+ QCOMPARE(getTypeRevision(rev2->typeEntry()), 2);
+
+ AbstractMetaEnum* rev3 = rev2->findEnum("Rev_3");
+ QCOMPARE(getTypeRevision(rev3->typeEntry()), 3);
+ FlagsTypeEntry* rev4 = rev3->typeEntry()->flags();
+ QCOMPARE(getTypeRevision(rev4), 4);
+ AbstractMetaEnum* rev5 = rev2->findEnum("Rev_5");
+ QCOMPARE(getTypeRevision(rev5->typeEntry()), 5);
+ QCOMPARE(getTypeRevision(rev5->typeEntry()->flags()), 5);
+}
+
+QTEST_APPLESS_MAIN(TestTypeRevision)
+
+#include "testtyperevision.moc"
+
diff --git a/tests/testtyperevision.h b/tests/testtyperevision.h
new file mode 100644
index 000000000..24e94739f
--- /dev/null
+++ b/tests/testtyperevision.h
@@ -0,0 +1,36 @@
+/*
+* This file is part of the API Extractor project.
+*
+* Copyright (C) 2011 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
+*/
+
+#ifndef TESTTYPEREVISION_H
+#define TESTTYPEREVISION_H
+
+#include <QObject>
+
+class TestTypeRevision : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testRevisionAttr();
+};
+
+#endif