diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2009-11-05 20:20:58 -0200 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2009-11-09 15:46:13 -0200 |
commit | 85be0d4d548bef2b249026d80dfb59274253bb17 (patch) | |
tree | aede83c7f66c126f01f9c2220615674e96a6e82d /tests/testreverseoperators.cpp | |
parent | 6067084bbfb6d479bcb886c73dba402c71257765 (diff) |
- All reverse operators are now properly tagged as "reverse operator".
- Reverse operators aren't tagged as static methods anymore.
- Reverse operators now have just one parameter, the one that matters.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests/testreverseoperators.cpp')
-rw-r--r-- | tests/testreverseoperators.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/testreverseoperators.cpp b/tests/testreverseoperators.cpp new file mode 100644 index 000000000..70ca8d264 --- /dev/null +++ b/tests/testreverseoperators.cpp @@ -0,0 +1,68 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2009 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 "testreverseoperators.h" +#include <QtTest/QTest> +#include "testutil.h" + + +void TestReverseOperators::testReverseSum() +{ + const char cppCode[] = "struct A {\ + A& operator+(int);\ + };\ + A& operator+(int, const A&);"; + const char xmlCode[] = "\ + <typesystem package=\"Foo\">\ + <primitive-type name='int' />\ + <value-type name='A' />\ + </typesystem>"; + + TestUtil t(cppCode, xmlCode, false); + AbstractMetaClassList classes = t.builder()->classes(); + AbstractMetaClass* classA = classes.findClass("A"); + QVERIFY(classA); + QCOMPARE(classA->functions().count(), 3); + + const AbstractMetaFunction* reverseOp = 0; + const AbstractMetaFunction* normalOp = 0; + foreach(const AbstractMetaFunction* func, classA->functions()) { + if (func->name() == "operator+") { + if (func->isReverseOperator()) + reverseOp = func; + else + normalOp = func; + } + } + + QVERIFY(normalOp); + QVERIFY(!normalOp->isReverseOperator()); + QCOMPARE(normalOp->arguments().count(), 1); + QVERIFY(reverseOp); + QVERIFY(reverseOp->isReverseOperator()); + QCOMPARE(reverseOp->arguments().count(), 1); +} + +QTEST_APPLESS_MAIN(TestReverseOperators) + +#include "testreverseoperators.moc" |