From 2cc6e2afa7b9845ccfc62b9dce72b498034e8de9 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 5 Jul 2011 19:11:04 -0300 Subject: 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. --- tests/CMakeLists.txt | 1 + tests/testtyperevision.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++ tests/testtyperevision.h | 36 ++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 tests/testtyperevision.cpp create mode 100644 tests/testtyperevision.h (limited to 'tests') 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 +* +* 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 +#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 = "" + "" + "" + "" + " " + " " + "" + ""; + 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 +* +* 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 + +class TestTypeRevision : public QObject +{ + Q_OBJECT + +private slots: + void testRevisionAttr(); +}; + +#endif -- cgit v1.2.3