From 5838074912905686475a2cb4ae9780c2532d424b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Nov 2022 13:16:14 -0800 Subject: qfloat16: add QTextStream & QDebug streaming operators Change-Id: Ieba79baf5ac34264a988fffd172655bdcaf12a59 Reviewed-by: Allan Sandfeld Jensen --- .../auto/corelib/global/qfloat16/tst_qfloat16.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 39470b7d30..9acbc2099a 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -4,6 +4,7 @@ #include #include +#include #include @@ -42,6 +43,7 @@ private slots: void limits(); void mantissaOverflow(); void dataStream(); + void textStream(); }; void tst_qfloat16::fuzzyCompare_data() @@ -656,5 +658,25 @@ void tst_qfloat16::dataStream() QCOMPARE(zero, qfloat16(0)); } +void tst_qfloat16::textStream() +{ + QString buffer; + { + QTextStream ts(&buffer); + ts << qfloat16(0) << Qt::endl << qfloat16(1.5); + QCOMPARE(ts.status(), QTextStream::Ok); + } + QCOMPARE(buffer, "0\n1.5"); + + { + QTextStream ts(&buffer); + qfloat16 zero = qfloat16(-2.5), threehalves = 1234; + ts >> zero >> threehalves; + QCOMPARE(ts.status(), QTextStream::Ok); + QCOMPARE(zero, qfloat16(0)); + QCOMPARE(threehalves, 1.5); + } +} + QTEST_APPLESS_MAIN(tst_qfloat16) #include "tst_qfloat16.moc" -- cgit v1.2.3