summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp')
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
index 6b98e3a823..241dccb90e 100644
--- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -46,6 +46,8 @@ private slots:
void promotionTests();
void arithOps_data();
void arithOps();
+ void floatToFloat16();
+ void floatFromFloat16();
};
void tst_qfloat16::fuzzyCompare_data()
@@ -307,5 +309,41 @@ void tst_qfloat16::arithOps()
QVERIFY(qFuzzyCompare(r4,1.f/val2));
}
+void tst_qfloat16::floatToFloat16()
+{
+ float in[63];
+ qfloat16 out[63];
+ qfloat16 expected[63];
+
+ for (int i = 0; i < 63; ++i)
+ in[i] = i * (1/13.f);
+
+ for (int i = 0; i < 63; ++i)
+ expected[i] = qfloat16(in[i]);
+
+ qFloatToFloat16(out, in, 63);
+
+ for (int i = 0; i < 63; ++i)
+ QVERIFY(qFuzzyCompare(out[i], expected[i]));
+}
+
+void tst_qfloat16::floatFromFloat16()
+{
+ qfloat16 in[35];
+ float out[35];
+ float expected[35];
+
+ for (int i = 0; i < 35; ++i)
+ in[i] = qfloat16(i * (17.f / 3));
+
+ for (int i = 0; i < 35; ++i)
+ expected[i] = float(in[i]);
+
+ qFloatFromFloat16(out, in, 35);
+
+ for (int i = 0; i < 35; ++i)
+ QCOMPARE(out[i], expected[i]);
+}
+
QTEST_APPLESS_MAIN(tst_qfloat16)
#include "tst_qfloat16.moc"