tst_QDebug: extend test with optionals of const or optional type
Amends b7657ddccbe0a5ab1cdfc61ae6b7f0501dbfb24a. Pick-to: 6.8 Change-Id: I420f11571629025a9d3b588d4ab124b34ee3811c Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
5e49278ab1
commit
dd672edd15
@ -1321,6 +1321,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::qDebugStdOrdering() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user