summaryrefslogtreecommitdiffstats
path: root/tests/testconversionoperator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testconversionoperator.cpp')
-rw-r--r--tests/testconversionoperator.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/testconversionoperator.cpp b/tests/testconversionoperator.cpp
new file mode 100644
index 0000000..cd4026b
--- /dev/null
+++ b/tests/testconversionoperator.cpp
@@ -0,0 +1,71 @@
+/*
+* 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 "testconversionoperator.h"
+#include <QtTest/QTest>
+#include "testutil.h"
+
+
+void TestConversionOperator::testConversionOperator()
+{
+ const char cppCode[] = "struct A {\
+ };\
+ struct B {\
+ operator A() const;\
+ };\
+ struct C {\
+ operator A() const;\
+ };";
+ const char xmlCode[] = "\
+ <typesystem package=\"Foo\">\
+ <value-type name='A' />\
+ <value-type name='B' />\
+ <value-type name='C' />\
+ </typesystem>";
+
+ TestUtil t(cppCode, xmlCode, false);
+ AbstractMetaClassList classes = t.builder()->classes();
+ AbstractMetaClass* classA = classes.findClass("A");
+ AbstractMetaClass* classB = classes.findClass("B");
+ AbstractMetaClass* classC = classes.findClass("C");
+ QVERIFY(classA);
+ QVERIFY(classB);
+ QVERIFY(classC);
+ QCOMPARE(classA->functions().count(), 1);
+ QCOMPARE(classB->functions().count(), 2);
+ QCOMPARE(classC->functions().count(), 2);
+ QCOMPARE(classA->externalConversionOperators().count(), 2);
+
+ const AbstractMetaFunction* convOp = 0;
+ foreach(const AbstractMetaFunction* func, classB->functions()) {
+ if (func->isConversionOperator())
+ convOp = func;
+ }
+ QVERIFY(convOp);
+ const AbstractMetaFunction* externalConvOp = classA->externalConversionOperators().first();
+ QCOMPARE(convOp, externalConvOp);
+}
+
+QTEST_APPLESS_MAIN(TestConversionOperator)
+
+#include "testconversionoperator.moc"