aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-17 14:58:30 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-29 00:06:14 +0200
commit733ffe48210c95c1fe30cb1ec2c2a61867e21b80 (patch)
treef11316b2b9a4fdddb7aa296f927596f4305e9443 /sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp
parent5c6382ee849c769e39d3a017966cfd4deb7dc15e (diff)
shiboken6: Add a test for std::shared_ptr
Task-number: PYSIDE-454 Change-Id: I67b89cccf4aae14b221fc13a98d53dd51f2a11e6 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp')
-rw-r--r--sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp b/sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp
new file mode 100644
index 000000000..3ee930041
--- /dev/null
+++ b/sources/shiboken6/tests/libsmart/stdsharedptrtestbench.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "stdsharedptrtestbench.h"
+#include "smart_integer.h"
+
+#include <iostream>
+
+StdSharedPtrTestBench::StdSharedPtrTestBench() = default;
+StdSharedPtrTestBench::~StdSharedPtrTestBench() = default;
+
+std::shared_ptr<Integer> StdSharedPtrTestBench::createInteger(int v)
+{
+ auto result = std::make_shared<Integer>();
+ result->setValue(v);
+ return result;
+}
+
+std::shared_ptr<Integer> StdSharedPtrTestBench::createNullInteger()
+{
+ return {};
+}
+
+void StdSharedPtrTestBench::printInteger(const std::shared_ptr<Integer> &p)
+{
+ std::cerr << __FUNCTION__ << ' ';
+ if (p.get())
+ std::cerr << p->value();
+ else
+ std::cerr << "nullptr";
+ std::cerr << '\n';
+}