[4/4] d3dx9/tests: Add tests for D3DXFloat32To16Array and D3DXFloat16To32Array.
Dylan Smith
dylan.ah.smith at gmail.com
Tue Mar 29 13:02:46 CDT 2011
Derived from a patch submitted by Misha Koshelev <misha680 at gmail.com>.
Added tests for rounding of denormalized number for D3DXFloat32To16Array.
---
dlls/d3dx9_36/tests/math.c | 74 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index 5ad1924..dd214c2 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/dlls/d3dx9_36/tests/math.c
@@ -21,6 +21,7 @@
#include "wine/test.h"
#include "d3dx9.h"
+#include <math.h>
#define ARRAY_SIZE 5
@@ -2215,6 +2216,78 @@ static void test_D3DXVec_Array(void)
compare_planes(exp_plane, out_plane);
}
+static void test_D3DXFloat_Array(void)
+{
+ unsigned int i;
+ void *out = NULL;
+ D3DXFLOAT16 half;
+ FLOAT single;
+ struct
+ {
+ FLOAT single_in;
+
+ /* half_ver2 occurs on WXPPROSP3 (32 bit math), WVISTAADM (32 bit math), W7PRO (32 bit math) */
+ WORD half_ver1, half_ver2;
+
+ /* single_out_ver2 confirms that half -> single conversion is consistent across platforms */
+ FLOAT single_out_ver1, single_out_ver2;
+ } testdata[] = {
+ { 80000.0f, 0x7c00, 0x7ce2, 65536.0f, 80000.0f },
+ { 65503.0f, 0x7bff, 0x7bff, 65504.0f, 65504.0f },
+ { 65504.0f, 0x7bff, 0x7bff, 65504.0f, 65504.0f },
+ { 65520.0f, 0x7bff, 0x7c00, 65504.0f, 65536.0f },
+ { 65521.0f, 0x7c00, 0x7c00, 65536.0f, 65536.0f },
+ { 65534.0f, 0x7c00, 0x7c00, 65536.0f, 65536.0f },
+ { 65535.0f, 0x7c00, 0x7c00, 65535.0f, 65536.0f },
+ { 65536.0f, 0x7c00, 0x7c00, 65536.0f, 65536.0f },
+ { -80000.0f, 0xfc00, 0xfce2, -65536.0f, -80000.0f },
+ { -65503.0f, 0xfbff, 0xfbff, -65504.0f, -65504.0f },
+ { -65504.0f, 0xfbff, 0xfbff, -65504.0f, -65504.0f },
+ { -65520.0f, 0xfbff, 0xfc00, -65504.0f, -65536.0f },
+ { -65521.0f, 0xfc00, 0xfc00, -65536.0f, -65536.0f },
+ { -65534.0f, 0xfc00, 0xfc00, -65536.0f, -65536.0f },
+ { -65535.0f, 0xfc00, 0xfc00, -65535.0f, -65536.0f },
+ { -65536.0f, 0xfc00, 0xfc00, -65536.0f, -65536.0f },
+ { INFINITY, 0x7c00, 0x7fff, 65536.0f, 131008.0f },
+ { -INFINITY, 0xffff, 0xffff, -131008.0f, -131008.0f },
+ { NAN, 0x7fff, 0x7fff, 131008.0f, 131008.0f },
+ { -NAN, 0xffff, 0xffff, -131008.0f, -131008.0f },
+ { 0.0f, 0x0, 0x0, 0.0f, 0.0f },
+ { -0.0f, 0x8000, 0x8000, 0.0f, 0.0f },
+ { 2.9809595e-08f, 0x0, 0x0, 0.0f, 0.0f },
+ { -2.9809595e-08f, 0x8000, 0x8000, -0.0f, -0.0f },
+ { 2.9809598e-08f, 0x1, 0x1, 5.96046e-08f, 5.96046e-08f },
+ { -2.9809598e-08f, 0x8001, 0x8001, -5.96046e-08f, -5.96046e-08f },
+ { 8.9406967e-08f, 0x2, 0x2, 1.19209e-07f, 1.19209e-07f }
+ };
+
+ /* exception on NULL out or in parameter */
+ out = D3DXFloat32To16Array(&half, &single, 0);
+ ok(out == &half, "Got %p, expected %p.\n", out, &half);
+
+ out = D3DXFloat16To32Array(&single, (D3DXFLOAT16 *)&half, 0);
+ ok(out == &single, "Got %p, expected %p.\n", out, &single);
+
+ for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++)
+ {
+ out = D3DXFloat32To16Array(&half, &testdata[i].single_in, 1);
+ ok(out == &half, "Got %p, expected %p.\n", out, &half);
+ ok(half.value == testdata[i].half_ver1 || half.value == testdata[i].half_ver2,
+ "Got %x, expected %x or %x for index %d.\n", half.value, testdata[i].half_ver1,
+ testdata[i].half_ver2, i);
+
+ out = D3DXFloat16To32Array(&single, (D3DXFLOAT16 *)&testdata[i].half_ver1, 1);
+ ok(out == &single, "Got %p, expected %p.\n", out, &single);
+ ok(relative_error(single, testdata[i].single_out_ver1) < admitted_error,
+ "Got %g, expected %g for index %d.\n", single, testdata[i].single_out_ver1, i);
+
+ out = D3DXFloat16To32Array(&single, (D3DXFLOAT16 *)&testdata[i].half_ver2, 1);
+ ok(out == &single, "Got %p, expected %p.\n", out, &single);
+ ok(relative_error(single, testdata[i].single_out_ver2) < admitted_error,
+ "Got %g, expected %g for index %d.\n", single, testdata[i].single_out_ver2, i);
+ }
+}
+
START_TEST(math)
{
D3DXColorTest();
@@ -2230,4 +2303,5 @@ START_TEST(math)
test_Matrix_Decompose();
test_Matrix_Transformation2D();
test_D3DXVec_Array();
+ test_D3DXFloat_Array();
}
--
1.7.2.5
More information about the wine-patches
mailing list