tst_QDebug: extend test with optionals of const or optional type

Amends b7657ddccbe0a5ab1cdfc61ae6b7f0501dbfb24a.

Change-Id: I420f11571629025a9d3b588d4ab124b34ee3811c
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit dd672edd15393378898b518091c3117a91c5bbfd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-10-24 15:12:35 +02:00 committed by Qt Cherry-pick Bot
parent e5e560c7fd
commit b6c102b742

View File

@ -1263,6 +1263,23 @@ void tst_QDebug::qDebugStdOptional() const
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
/* simpler tests from now on */
// const
qDebug() << std::optional<const int>(42) << std::optional<const int>(std::nullopt);
QCOMPARE(s_msg, R"(std::optional(42) nullopt)"_L1);
// nested
{
auto d = qDebug();
// the constructors would do the wrong thing (convert payload types), so use emplace()
std::optional<std::optional<int>> opt;
d << opt;
opt.emplace();
d << opt;
*opt = 42;
d << opt;
}
QCOMPARE(s_msg, R"(nullopt std::optional(nullopt) std::optional(std::optional(42)))"_L1);
}
void tst_QDebug::textStreamModifiers() const