diff options
Diffstat (limited to 'sources/shiboken6/tests/libsmart/stdoptionaltestbench.cpp')
-rw-r--r-- | sources/shiboken6/tests/libsmart/stdoptionaltestbench.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsmart/stdoptionaltestbench.cpp b/sources/shiboken6/tests/libsmart/stdoptionaltestbench.cpp new file mode 100644 index 000000000..69100720c --- /dev/null +++ b/sources/shiboken6/tests/libsmart/stdoptionaltestbench.cpp @@ -0,0 +1,58 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "stdoptionaltestbench.h" + +#include <iostream> + +std::ostream &operator<<(std::ostream &str, const Integer &i) +{ + str << i.value(); + return str; +} + +template <class T> +std::ostream &operator<<(std::ostream &str, const std::optional<T> &o) +{ + if (o.has_value()) + str << o.value(); + else + str << "nullopt"; + return str; +} + +StdOptionalTestBench::StdOptionalTestBench() = default; + +std::optional<int> StdOptionalTestBench::optionalInt() const +{ + return m_optionalInt; +} + +void StdOptionalTestBench::setOptionalInt(const std::optional<int> &i) +{ + std::cout << __FUNCTION__ << ' ' << i << '\n'; + m_optionalInt = i; +} + +void StdOptionalTestBench::setOptionalIntValue(int i) +{ + std::cout << __FUNCTION__ << ' ' << i << '\n'; + m_optionalInt.emplace(i); +} + +std::optional<Integer> StdOptionalTestBench::optionalInteger() const +{ + return m_optionalInteger; +} + +void StdOptionalTestBench::setOptionalInteger(const std::optional<Integer> &s) +{ + std::cout << __FUNCTION__ << ' ' << s << '\n'; + m_optionalInteger = s; +} + +void StdOptionalTestBench::setOptionalIntegerValue(Integer &s) +{ + std::cout << __FUNCTION__ << ' ' << s << '\n'; + m_optionalInteger.emplace(s); +} |