diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp b/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp new file mode 100644 index 000000000..99cced09d --- /dev/null +++ b/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "testprimitivetypetag.h" +#include "testutil.h" +#include <abstractmetalang.h> +#include <primitivetypeentry.h> + +#include <qtcompat.h> + +#include <QtTest/QTest> + +using namespace Qt::StringLiterals; + +void TestPrimitiveTypeTag::testPrimitiveTypeDefaultConstructor() +{ + const char cppCode[] = "\ + struct A {};\n\ + struct B {};\n"; + const char xmlCode[] = "\ + <typesystem package=\"Foo\">\n\ + <primitive-type name='A' default-constructor='A()'/>\n\ + <object-type name='B'/>\n\ + </typesystem>\n"; + QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false)); + QVERIFY(builder); + + AbstractMetaClassList classes = builder->classes(); + QCOMPARE(classes.size(), 1); + const auto classB = AbstractMetaClass::findClass(classes, "B"); + QVERIFY(classB); + + auto typeEntry = TypeDatabase::instance()->findPrimitiveType(u"A"_s); + QVERIFY(typeEntry); + QVERIFY(typeEntry->hasDefaultConstructor()); + QCOMPARE(typeEntry->defaultConstructor(), u"A()"); +} + +QTEST_APPLESS_MAIN(TestPrimitiveTypeTag) + |