summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-11-10 13:16:14 -0800
committerThiago Macieira <thiago.macieira@intel.com>2022-11-28 10:59:34 -0800
commit5838074912905686475a2cb4ae9780c2532d424b (patch)
tree0345559d3e715b7129046c2ab4bb5abfaba20b65 /tests/auto
parentc53bf1b45e414f25037dad0d02f3829dd83c11f5 (diff)
qfloat16: add QTextStream & QDebug streaming operators
Change-Id: Ieba79baf5ac34264a988fffd172655bdcaf12a59 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp22
1 files changed, 22 insertions, 0 deletions
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 <QTest>
#include <QFloat16>
+#include <QTextStream>
#include <math.h>
@@ -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"