crypt32: Make sure we show Unicode characters (Dutch translation).
[wine] / dlls / d3dx8 / tests / math.c
1 /*
2  * Copyright 2007 David Adam
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include <assert.h>
20 #include "d3dx8.h"
21
22 #include "wine/test.h"
23
24 #define admitted_error 0.0001f
25
26 #define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(expectedcolor.a-gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
27
28 static inline BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
29 {
30     int i, j;
31
32     for (i = 0; i < 4; ++i)
33     {
34         for (j = 0; j < 4; ++j)
35         {
36             if (fabs(U(*m1).m[i][j] - U(*m2).m[i][j]) > admitted_error)
37                 return FALSE;
38         }
39     }
40
41     return TRUE;
42 }
43
44 #define expect_mat(expectedmat, gotmat) \
45 do { \
46     const D3DXMATRIX *__m1 = (expectedmat); \
47     const D3DXMATRIX *__m2 = (gotmat); \
48     ok(compare_matrix(__m1, __m2), "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
49             "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
50             U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
51             U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
52             U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
53             U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
54             U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
55             U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
56             U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
57             U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
58 } while(0)
59
60 #define expect_plane(expectedplane,gotplane) ok((fabs(expectedplane.a-gotplane.a)<admitted_error)&&(fabs(expectedplane.b-gotplane.b)<admitted_error)&&(fabs(expectedplane.c-gotplane.c)<admitted_error)&&(fabs(expectedplane.d-gotplane.d)<admitted_error),"Expected Plane= (%f, %f, %f, %f)\n , Got Plane= (%f, %f, %f, %f)\n", expectedplane.a, expectedplane.b, expectedplane.c, expectedplane.d, gotplane.a, gotplane.b, gotplane.c, gotplane.d);
61
62 #define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
63
64 #define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
65
66 #define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error)&&(fabs(expectedvec.w-gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
67
68 static void D3DXColorTest(void)
69 {
70     D3DXCOLOR color, color1, color2, expected, got;
71     LPD3DXCOLOR funcpointer;
72     FLOAT scale;
73
74     color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
75     color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
76     color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
77
78     scale = 0.3f;
79
80 /*_______________D3DXColorAdd________________*/
81     expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
82     D3DXColorAdd(&got,&color1,&color2);
83     expect_color(expected,got);
84     /* Test the NULL case */
85     funcpointer = D3DXColorAdd(&got,NULL,&color2);
86     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
87     funcpointer = D3DXColorAdd(NULL,NULL,&color2);
88     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
89     funcpointer = D3DXColorAdd(NULL,NULL,NULL);
90     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
91
92 /*_______________D3DXColorAdjustContrast______*/
93     expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f, expected.a = 0.93f;
94     D3DXColorAdjustContrast(&got,&color,scale);
95     expect_color(expected,got);
96
97 /*_______________D3DXColorAdjustSaturation______*/
98     expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f, expected.a = 0.93f;
99     D3DXColorAdjustSaturation(&got,&color,scale);
100     expect_color(expected,got);
101
102 /*_______________D3DXColorLerp________________*/
103     expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
104     D3DXColorLerp(&got,&color,&color1,scale);
105     expect_color(expected,got);
106     /* Test the NULL case */
107     funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
108     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
109     funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
110     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
111     funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
112     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
113
114 /*_______________D3DXColorModulate________________*/
115     expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
116     D3DXColorModulate(&got,&color1,&color2);
117     expect_color(expected,got);
118     /* Test the NULL case */
119     funcpointer = D3DXColorModulate(&got,NULL,&color2);
120     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
121     funcpointer = D3DXColorModulate(NULL,NULL,&color2);
122     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
123     funcpointer = D3DXColorModulate(NULL,NULL,NULL);
124     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
125
126 /*_______________D3DXColorNegative________________*/
127     expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
128     D3DXColorNegative(&got,&color);
129     expect_color(got,expected);
130     /* Test the greater than 1 case */
131     color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
132     expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
133     D3DXColorNegative(&got,&color1);
134     expect_color(got,expected);
135     /* Test the negative case */
136     color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
137     expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
138     D3DXColorNegative(&got,&color1);
139     expect_color(got,expected);
140     /* Test the NULL case */
141     funcpointer = D3DXColorNegative(&got,NULL);
142     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
143     funcpointer = D3DXColorNegative(NULL,NULL);
144     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
145
146 /*_______________D3DXColorScale________________*/
147     expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
148     D3DXColorScale(&got,&color,scale);
149     expect_color(expected,got);
150     /* Test the NULL case */
151     funcpointer = D3DXColorScale(&got,NULL,scale);
152     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
153     funcpointer = D3DXColorScale(NULL,NULL,scale);
154     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
155
156 /*_______________D3DXColorSubtract_______________*/
157     expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
158     D3DXColorSubtract(&got,&color,&color2);
159     expect_color(expected,got);
160     /* Test the NULL case */
161     funcpointer = D3DXColorSubtract(&got,NULL,&color2);
162     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
163     funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
164     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
165     funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
166     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
167 }
168
169 static void D3DXFresnelTest(void)
170 {
171     FLOAT expected, got;
172
173     expected = 0.089187;
174     got = D3DXFresnelTerm(0.5f,1.5);
175     ok( fabs(got - expected) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
176 }
177
178 static void D3DXMatrixTest(void)
179 {
180     D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3;
181     LPD3DXMATRIX funcpointer;
182     D3DXPLANE plane;
183     D3DXQUATERNION q, r;
184     D3DXVECTOR3 at, axis, eye, last, scaling;
185     D3DXVECTOR4 light;
186     BOOL expected, got;
187     FLOAT angle, determinant, expectedfloat, gotfloat;
188
189     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
190     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
191     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
192     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
193     U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
194     U(mat).m[3][3] = -40.0f;
195
196     U(mat2).m[0][0] = 1.0f; U(mat2).m[1][0] = 2.0f; U(mat2).m[2][0] = 3.0f;
197     U(mat2).m[3][0] = 4.0f; U(mat2).m[0][1] = 5.0f; U(mat2).m[1][1] = 6.0f;
198     U(mat2).m[2][1] = 7.0f; U(mat2).m[3][1] = 8.0f; U(mat2).m[0][2] = -8.0f;
199     U(mat2).m[1][2] = -7.0f; U(mat2).m[2][2] = -6.0f; U(mat2).m[3][2] = -5.0f;
200     U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f;
201     U(mat2).m[3][3] = -1.0f;
202
203     plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
204
205     q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
206     r.x = 0.87f; r.y = 0.65f; r.z =0.43f; r.w= 0.21f;
207
208     at.x = -2.0f; at.y = 13.0f; at.z = -9.0f;
209     axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f;
210     eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
211     last.x = 9.7f; last.y = -8.6; last.z = 1.3f;
212     scaling.x = 0.03f; scaling.y =0.05f; scaling.z = 0.06f;
213
214     light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3;
215
216     angle = D3DX_PI/3.0f;
217
218 /*____________D3DXMatrixAffineTransformation______*/
219     U(expectedmat).m[0][0] = -459.239990f; U(expectedmat).m[0][1] = -576.719971f; U(expectedmat).m[0][2] = -263.440002f; U(expectedmat).m[0][3] = 0.0f;
220     U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f;
221     U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f;
222     U(expectedmat).m[3][0] = -1239.0f; U(expectedmat).m[3][1] = 667.0f; U(expectedmat).m[3][2] = 567.0f; U(expectedmat).m[3][3] = 1.0f;
223     D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis);
224     expect_mat(&expectedmat, &gotmat);
225 /* Test the NULL case */
226     U(expectedmat).m[0][0] = -459.239990f; U(expectedmat).m[0][1] = -576.719971f; U(expectedmat).m[0][2] = -263.440002f; U(expectedmat).m[0][3] = 0.0f;
227     U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f;
228     U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f;
229     U(expectedmat).m[3][0] = 1.0f; U(expectedmat).m[3][1] = -3.0f; U(expectedmat).m[3][2] = 7.0f; U(expectedmat).m[3][3] = 1.0f;
230     D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis);
231     expect_mat(&expectedmat, &gotmat);
232
233 /*____________D3DXMatrixfDeterminant_____________*/
234     expectedfloat = -147888.0f;
235     gotfloat = D3DXMatrixfDeterminant(&mat);
236     ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat);
237
238 /*____________D3DXMatrixInverse______________*/
239     U(expectedmat).m[0][0] = 16067.0f/73944.0f; U(expectedmat).m[0][1] = -10165.0f/147888.0f; U(expectedmat).m[0][2] = -2729.0f/147888.0f; U(expectedmat).m[0][3] = -1631.0f/49296.0f;
240     U(expectedmat).m[1][0] = -565.0f/36972.0f; U(expectedmat).m[1][1] = 2723.0f/73944.0f; U(expectedmat).m[1][2] = -1073.0f/73944.0f; U(expectedmat).m[1][3] = 289.0f/24648.0f;
241     U(expectedmat).m[2][0] = -389.0f/2054.0f; U(expectedmat).m[2][1] = 337.0f/4108.0f; U(expectedmat).m[2][2] = 181.0f/4108.0f; U(expectedmat).m[2][3] = 317.0f/4108.0f;
242     U(expectedmat).m[3][0] = 163.0f/5688.0f; U(expectedmat).m[3][1] = -101.0f/11376.0f; U(expectedmat).m[3][2] = -73.0f/11376.0f; U(expectedmat).m[3][3] = -127.0f/3792.0f;
243     expectedfloat = -147888.0f;
244     D3DXMatrixInverse(&gotmat,&determinant,&mat);
245     expect_mat(&expectedmat, &gotmat);
246     ok(fabs( determinant - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, determinant);
247     funcpointer = D3DXMatrixInverse(&gotmat,NULL,&mat2);
248     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
249
250 /*____________D3DXMatrixIsIdentity______________*/
251     expected = FALSE;
252     memset(&mat3, 0, sizeof(mat3));
253     got = D3DXMatrixIsIdentity(&mat3);
254     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
255     D3DXMatrixIdentity(&mat3);
256     expected = TRUE;
257     got = D3DXMatrixIsIdentity(&mat3);
258     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
259     U(mat3).m[0][0] = 0.000009f;
260     expected = FALSE;
261     got = D3DXMatrixIsIdentity(&mat3);
262     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
263     /* Test the NULL case */
264     expected = FALSE;
265     got = D3DXMatrixIsIdentity(NULL);
266     ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
267
268 /*____________D3DXMatrixLookatLH_______________*/
269     U(expectedmat).m[0][0] = -0.822465f; U(expectedmat).m[0][1] = -0.409489f; U(expectedmat).m[0][2] = -0.394803f; U(expectedmat).m[0][3] = 0.0f;
270     U(expectedmat).m[1][0] = -0.555856f; U(expectedmat).m[1][1] = 0.431286f; U(expectedmat).m[1][2] = 0.710645f; U(expectedmat).m[1][3] = 0.0f;
271     U(expectedmat).m[2][0] = -0.120729f; U(expectedmat).m[2][1] = 0.803935f; U(expectedmat).m[2][2] = -0.582335f; U(expectedmat).m[2][3] = 0.0f;
272     U(expectedmat).m[3][0] = 4.494634f; U(expectedmat).m[3][1] = 0.809719f; U(expectedmat).m[3][2] = 10.060076f; U(expectedmat).m[3][3] = 1.0f;
273     D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
274     expect_mat(&expectedmat, &gotmat);
275
276 /*____________D3DXMatrixLookatRH_______________*/
277     U(expectedmat).m[0][0] = 0.822465f; U(expectedmat).m[0][1] = -0.409489f; U(expectedmat).m[0][2] = 0.394803f; U(expectedmat).m[0][3] = 0.0f;
278     U(expectedmat).m[1][0] = 0.555856f; U(expectedmat).m[1][1] = 0.431286f; U(expectedmat).m[1][2] = -0.710645f; U(expectedmat).m[1][3] = 0.0f;
279     U(expectedmat).m[2][0] = 0.120729f; U(expectedmat).m[2][1] = 0.803935f; U(expectedmat).m[2][2] = 0.582335f; U(expectedmat).m[2][3] = 0.0f;
280     U(expectedmat).m[3][0] = -4.494634f; U(expectedmat).m[3][1] = 0.809719f; U(expectedmat).m[3][2] = -10.060076f; U(expectedmat).m[3][3] = 1.0f;
281     D3DXMatrixLookAtRH(&gotmat,&eye,&at,&axis);
282     expect_mat(&expectedmat, &gotmat);
283
284 /*____________D3DXMatrixMultiply______________*/
285     U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 193.0f; U(expectedmat).m[0][2] = -197.0f; U(expectedmat).m[0][3] = -77.0f;
286     U(expectedmat).m[1][0] = 231.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = -489.0f; U(expectedmat).m[1][3] = -169.0;
287     U(expectedmat).m[2][0] = 239.0f; U(expectedmat).m[2][1] = 523.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = -116.0f;
288     U(expectedmat).m[3][0] = -164.0f; U(expectedmat).m[3][1] = -320.0f; U(expectedmat).m[3][2] = 187.0f; U(expectedmat).m[3][3] = 31.0f;
289     D3DXMatrixMultiply(&gotmat,&mat,&mat2);
290     expect_mat(&expectedmat, &gotmat);
291
292 /*____________D3DXMatrixMultiplyTranspose____*/
293     U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 231.0f; U(expectedmat).m[0][2] = 239.0f; U(expectedmat).m[0][3] = -164.0f;
294     U(expectedmat).m[1][0] = 193.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = 523.0f; U(expectedmat).m[1][3] = -320.0;
295     U(expectedmat).m[2][0] = -197.0f; U(expectedmat).m[2][1] = -489.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = 187.0f;
296     U(expectedmat).m[3][0] = -77.0f; U(expectedmat).m[3][1] = -169.0f; U(expectedmat).m[3][2] = -116.0f; U(expectedmat).m[3][3] = 31.0f;
297     D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2);
298     expect_mat(&expectedmat, &gotmat);
299
300 /*____________D3DXMatrixOrthoLH_______________*/
301     U(expectedmat).m[0][0] = 0.8f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
302     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.270270f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
303     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.151515f; U(expectedmat).m[2][3] = 0.0f;
304     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -0.484848f; U(expectedmat).m[3][3] = 1.0f;
305     D3DXMatrixOrthoLH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
306     expect_mat(&expectedmat, &gotmat);
307
308 /*____________D3DXMatrixOrthoOffCenterLH_______________*/
309     U(expectedmat).m[0][0] = 3.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
310     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.180180f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
311     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.045662f; U(expectedmat).m[2][3] = 0.0f;
312     U(expectedmat).m[3][0] = -1.727272f; U(expectedmat).m[3][1] = -0.567568f; U(expectedmat).m[3][2] = 0.424658f; U(expectedmat).m[3][3] = 1.0f;
313     D3DXMatrixOrthoOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
314     expect_mat(&expectedmat, &gotmat);
315
316 /*____________D3DXMatrixOrthoOffCenterRH_______________*/
317     U(expectedmat).m[0][0] = 3.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
318     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.180180f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
319     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.045662f; U(expectedmat).m[2][3] = 0.0f;
320     U(expectedmat).m[3][0] = -1.727272f; U(expectedmat).m[3][1] = -0.567568f; U(expectedmat).m[3][2] = 0.424658f; U(expectedmat).m[3][3] = 1.0f;
321     D3DXMatrixOrthoOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 9.3, -12.6);
322     expect_mat(&expectedmat, &gotmat);
323
324 /*____________D3DXMatrixOrthoRH_______________*/
325     U(expectedmat).m[0][0] = 0.8f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
326     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.270270f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
327     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.151515f; U(expectedmat).m[2][3] = 0.0f;
328     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -0.484848f; U(expectedmat).m[3][3] = 1.0f;
329     D3DXMatrixOrthoRH(&gotmat, 2.5f, 7.4f, -3.2f, -9.8f);
330     expect_mat(&expectedmat, &gotmat);
331
332 /*____________D3DXMatrixPerspectiveFovLH_______________*/
333     U(expectedmat).m[0][0] = 13.288858f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
334     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 9.966644f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
335     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.783784f; U(expectedmat).m[2][3] = 1.0f;
336     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
337     D3DXMatrixPerspectiveFovLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
338     expect_mat(&expectedmat, &gotmat);
339
340 /*____________D3DXMatrixPerspectiveFovRH_______________*/
341     U(expectedmat).m[0][0] = 13.288858f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
342     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 9.966644f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
343     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.783784f; U(expectedmat).m[2][3] = -1.0f;
344     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
345     D3DXMatrixPerspectiveFovRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
346     expect_mat(&expectedmat, &gotmat);
347
348 /*____________D3DXMatrixPerspectiveLH_______________*/
349     U(expectedmat).m[0][0] = -24.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
350     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = -6.4f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
351     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.783784f; U(expectedmat).m[2][3] = 1.0f;
352     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
353     D3DXMatrixPerspectiveLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
354     expect_mat(&expectedmat, &gotmat);
355
356 /*____________D3DXMatrixPerspectiveOffCenterLH_______________*/
357     U(expectedmat).m[0][0] = 11.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
358     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.576577f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
359     U(expectedmat).m[2][0] = -1.727273f; U(expectedmat).m[2][1] = -0.567568f; U(expectedmat).m[2][2] = 0.840796f; U(expectedmat).m[2][3] = 1.0f;
360     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -2.690547f; U(expectedmat).m[3][3] = 0.0f;
361     D3DXMatrixPerspectiveOffCenterLH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
362     expect_mat(&expectedmat, &gotmat);
363
364 /*____________D3DXMatrixPerspectiveOffCenterRH_______________*/
365     U(expectedmat).m[0][0] = 11.636364f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
366     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = 0.576577f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
367     U(expectedmat).m[2][0] = 1.727273f; U(expectedmat).m[2][1] = 0.567568f; U(expectedmat).m[2][2] = -0.840796f; U(expectedmat).m[2][3] = -1.0f;
368     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = -2.690547f; U(expectedmat).m[3][3] = 0.0f;
369     D3DXMatrixPerspectiveOffCenterRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f, 3.2f, -16.9f);
370     expect_mat(&expectedmat, &gotmat);
371
372 /*____________D3DXMatrixPerspectiveRH_______________*/
373     U(expectedmat).m[0][0] = -24.0f; U(expectedmat).m[0][1] = -0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
374     U(expectedmat).m[1][0] = 0.0f; U(expectedmat).m[1][1] = -6.4f; U(expectedmat).m[1][2] = 0.0; U(expectedmat).m[1][3] = 0.0f;
375     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = -0.783784f; U(expectedmat).m[2][3] = -1.0f;
376     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 1.881081f; U(expectedmat).m[3][3] = 0.0f;
377     D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
378     expect_mat(&expectedmat, &gotmat);
379
380 /*____________D3DXMatrixReflect______________*/
381     U(expectedmat).m[0][0] = 0.307692f; U(expectedmat).m[0][1] = -0.230769f; U(expectedmat).m[0][2] = 0.923077f; U(expectedmat).m[0][3] = 0.0f;
382     U(expectedmat).m[1][0] = -0.230769; U(expectedmat).m[1][1] = 0.923077f; U(expectedmat).m[1][2] = 0.307693f; U(expectedmat).m[1][3] = 0.0f;
383     U(expectedmat).m[2][0] = 0.923077f; U(expectedmat).m[2][1] = 0.307693f; U(expectedmat).m[2][2] = -0.230769f; U(expectedmat).m[2][3] = 0.0f;
384     U(expectedmat).m[3][0] = 1.615385f; U(expectedmat).m[3][1] = 0.538462f; U(expectedmat).m[3][2] = -2.153846f; U(expectedmat).m[3][3] = 1.0f;
385     D3DXMatrixReflect(&gotmat,&plane);
386     expect_mat(&expectedmat, &gotmat);
387
388 /*____________D3DXMatrixRotationAxis_____*/
389     U(expectedmat).m[0][0] = 0.508475f; U(expectedmat).m[0][1] = 0.763805f; U(expectedmat).m[0][2] = 0.397563f; U(expectedmat).m[0][3] = 0.0f;
390     U(expectedmat).m[1][0] = -0.814652f; U(expectedmat).m[1][1] = 0.576271f; U(expectedmat).m[1][2] = -0.065219f; U(expectedmat).m[1][3] = 0.0f;
391     U(expectedmat).m[2][0] = -0.278919f; U(expectedmat).m[2][1] = -0.290713f; U(expectedmat).m[2][2] = 0.915254f; U(expectedmat).m[2][3] = 0.0f;
392     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
393     D3DXMatrixRotationAxis(&gotmat,&axis,angle);
394     expect_mat(&expectedmat, &gotmat);
395
396 /*____________D3DXMatrixRotationQuaternion______________*/
397     U(expectedmat).m[0][0] = -129.0f; U(expectedmat).m[0][1] = -162.0f; U(expectedmat).m[0][2] = -74.0f; U(expectedmat).m[0][3] = 0.0f;
398     U(expectedmat).m[1][0] = 146.0f; U(expectedmat).m[1][1] = -99.0f; U(expectedmat).m[1][2] = -78.0f; U(expectedmat).m[1][3] = 0.0f;
399     U(expectedmat).m[2][0] = 102.0f; U(expectedmat).m[2][1] = -34.0f; U(expectedmat).m[2][2] = -33.0f; U(expectedmat).m[2][3] = 0.0f;
400     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
401     D3DXMatrixRotationQuaternion(&gotmat,&q);
402     expect_mat(&expectedmat, &gotmat);
403
404 /*____________D3DXMatrixRotationX______________*/
405     U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
406     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 0.5f; U(expectedmat).m[1][2] = sqrt(3.0f)/2.0f; U(expectedmat).m[1][3] = 0.0f;
407     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = -sqrt(3.0f)/2.0f; U(expectedmat).m[2][2] = 0.5f; U(expectedmat).m[2][3] = 0.0f;
408     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
409     D3DXMatrixRotationX(&gotmat,angle);
410     expect_mat(&expectedmat, &gotmat);
411
412 /*____________D3DXMatrixRotationY______________*/
413     U(expectedmat).m[0][0] = 0.5f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = -sqrt(3.0f)/2.0f; U(expectedmat).m[0][3] = 0.0f;
414     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
415     U(expectedmat).m[2][0] = sqrt(3.0f)/2.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 0.5f; U(expectedmat).m[2][3] = 0.0f;
416     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
417     D3DXMatrixRotationY(&gotmat,angle);
418     expect_mat(&expectedmat, &gotmat);
419
420 /*____________D3DXMatrixRotationYawPitchRoll____*/
421     U(expectedmat).m[0][0] = 0.888777f; U(expectedmat).m[0][1] = 0.091875f; U(expectedmat).m[0][2] = -0.449037f; U(expectedmat).m[0][3] = 0.0f;
422     U(expectedmat).m[1][0] = 0.351713f; U(expectedmat).m[1][1] = 0.491487f; U(expectedmat).m[1][2] = 0.796705f; U(expectedmat).m[1][3] = 0.0f;
423     U(expectedmat).m[2][0] = 0.293893f; U(expectedmat).m[2][1] = -0.866025f; U(expectedmat).m[2][2] = 0.404509f; U(expectedmat).m[2][3] = 0.0f;
424     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
425     D3DXMatrixRotationYawPitchRoll(&gotmat, 3.0f*angle/5.0f, angle, 3.0f*angle/17.0f);
426     expect_mat(&expectedmat, &gotmat);
427
428 /*____________D3DXMatrixRotationZ______________*/
429     U(expectedmat).m[0][0] = 0.5f; U(expectedmat).m[0][1] = sqrt(3.0f)/2.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
430     U(expectedmat).m[1][0] = -sqrt(3.0f)/2.0f; U(expectedmat).m[1][1] = 0.5f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
431     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 1.0f; U(expectedmat).m[2][3] = 0.0f;
432     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
433     D3DXMatrixRotationZ(&gotmat,angle);
434     expect_mat(&expectedmat, &gotmat);
435
436 /*____________D3DXMatrixScaling______________*/
437     U(expectedmat).m[0][0] = 0.69f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
438     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 0.53f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
439     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 4.11f; U(expectedmat).m[2][3] = 0.0f;
440     U(expectedmat).m[3][0] = 0.0f; U(expectedmat).m[3][1] = 0.0f; U(expectedmat).m[3][2] = 0.0f; U(expectedmat).m[3][3] = 1.0f;
441     D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
442     expect_mat(&expectedmat, &gotmat);
443
444 /*____________D3DXMatrixShadow______________*/
445     U(expectedmat).m[0][0] = 12.786773f; U(expectedmat).m[0][1] = 5.000961f; U(expectedmat).m[0][2] = 4.353778f; U(expectedmat).m[0][3] = 3.706595f;
446     U(expectedmat).m[1][0] = 1.882715; U(expectedmat).m[1][1] = 8.805615f; U(expectedmat).m[1][2] = 1.451259f; U(expectedmat).m[1][3] = 1.235532f;
447     U(expectedmat).m[2][0] = -7.530860f; U(expectedmat).m[2][1] = -6.667949f; U(expectedmat).m[2][2] = 1.333590f; U(expectedmat).m[2][3] = -4.942127f;
448     U(expectedmat).m[3][0] = -13.179006f; U(expectedmat).m[3][1] = -11.668910f; U(expectedmat).m[3][2] = -10.158816f; U(expectedmat).m[3][3] = -1.510094f;
449     D3DXMatrixShadow(&gotmat,&light,&plane);
450     expect_mat(&expectedmat, &gotmat);
451
452 /*____________D3DXMatrixTransformation______________*/
453     U(expectedmat).m[0][0] = -0.2148f; U(expectedmat).m[0][1] = 1.3116f; U(expectedmat).m[0][2] = 0.4752f; U(expectedmat).m[0][3] = 0.0f;
454     U(expectedmat).m[1][0] = 0.9504f; U(expectedmat).m[1][1] = -0.8836f; U(expectedmat).m[1][2] = 0.9244f; U(expectedmat).m[1][3] = 0.0f;
455     U(expectedmat).m[2][0] = 1.0212f; U(expectedmat).m[2][1] = 0.1936f; U(expectedmat).m[2][2] = -1.3588f; U(expectedmat).m[2][3] = 0.0f;
456     U(expectedmat).m[3][0] = 18.2985f; U(expectedmat).m[3][1] = -29.624001f; U(expectedmat).m[3][2] = 15.683499f; U(expectedmat).m[3][3] = 1.0f;
457     D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last);
458     expect_mat(&expectedmat, &gotmat);
459
460 /*____________D3DXMatrixTranslation______________*/
461     U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f;
462     U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f;
463     U(expectedmat).m[2][0] = 0.0f; U(expectedmat).m[2][1] = 0.0f; U(expectedmat).m[2][2] = 1.0f; U(expectedmat).m[2][3] = 0.0f;
464     U(expectedmat).m[3][0] = 0.69f; U(expectedmat).m[3][1] = 0.53f; U(expectedmat).m[3][2] = 4.11f; U(expectedmat).m[3][3] = 1.0f;
465     D3DXMatrixTranslation(&gotmat,0.69f,0.53f,4.11f);
466     expect_mat(&expectedmat, &gotmat);
467
468 /*____________D3DXMatrixTranspose______________*/
469     U(expectedmat).m[0][0] = 10.0f; U(expectedmat).m[0][1] = 11.0f; U(expectedmat).m[0][2] = 19.0f; U(expectedmat).m[0][3] = 2.0f;
470     U(expectedmat).m[1][0] = 5.0; U(expectedmat).m[1][1] = 20.0f; U(expectedmat).m[1][2] = -21.0f; U(expectedmat).m[1][3] = 3.0f;
471     U(expectedmat).m[2][0] = 7.0f; U(expectedmat).m[2][1] = 16.0f; U(expectedmat).m[2][2] = 30.f; U(expectedmat).m[2][3] = -4.0f;
472     U(expectedmat).m[3][0] = 8.0f; U(expectedmat).m[3][1] = 33.0f; U(expectedmat).m[3][2] = 43.0f; U(expectedmat).m[3][3] = -40.0f;
473     D3DXMatrixTranspose(&gotmat,&mat);
474     expect_mat(&expectedmat, &gotmat);
475 }
476
477 static void D3DXPlaneTest(void)
478 {
479     D3DXMATRIX mat;
480     D3DXPLANE expectedplane, gotplane, nulplane, plane;
481     D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
482     LPD3DXVECTOR3 funcpointer;
483     D3DXVECTOR4 vec;
484     FLOAT expected, got;
485
486     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
487     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
488     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
489     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
490     U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
491     U(mat).m[3][3] = -40.0f;
492
493     plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
494
495     vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
496
497 /*_______________D3DXPlaneDot________________*/
498     expected = 42.0f;
499     got = D3DXPlaneDot(&plane,&vec),
500     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
501     expected = 0.0f;
502     got = D3DXPlaneDot(NULL,&vec),
503     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
504     expected = 0.0f;
505     got = D3DXPlaneDot(NULL,NULL),
506     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
507
508 /*_______________D3DXPlaneDotCoord________________*/
509     expected = -28.0f;
510     got = D3DXPlaneDotCoord(&plane,&vec),
511     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
512     expected = 0.0f;
513     got = D3DXPlaneDotCoord(NULL,&vec),
514     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
515     expected = 0.0f;
516     got = D3DXPlaneDotCoord(NULL,NULL),
517     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
518
519 /*_______________D3DXPlaneDotNormal______________*/
520     expected = -35.0f;
521     got = D3DXPlaneDotNormal(&plane,&vec),
522     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
523     expected = 0.0f;
524     got = D3DXPlaneDotNormal(NULL,&vec),
525     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
526     expected = 0.0f;
527     got = D3DXPlaneDotNormal(NULL,NULL),
528     ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
529
530 /*_______________D3DXPlaneFromPointNormal_______*/
531     vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
532     vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
533     expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f;
534     D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2);
535     expect_plane(expectedplane, gotplane);
536
537 /*_______________D3DXPlaneFromPoints_______*/
538     vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f;
539     vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f;
540     vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f;
541     expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f;
542     D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
543     expect_plane(expectedplane, gotplane);
544     /* Test if 2 vectors are parallels */
545     vec3.x = 1.0f; vec3.y = 1.0f; vec3.z = 2.0f;
546     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
547     D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3);
548     expect_plane(expectedplane, gotplane);
549
550 /*_______________D3DXPlaneIntersectLine___________*/
551     vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f;
552     vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f;
553     expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
554     D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
555     expect_vec3(expectedvec, gotvec);
556     /* Test a parallel line */
557     vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f;
558     vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f;
559     expectedvec.x = 20.0f/3.0f; expectedvec.y = 17.0f/3.0f; expectedvec.z = 14.0f/3.0f;
560     funcpointer = D3DXPlaneIntersectLine(&gotvec,&plane,&vec1,&vec2);
561     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
562
563 /*_______________D3DXPlaneNormalize______________*/
564     expectedplane.a = -3.0f/sqrt(26.0f); expectedplane.b = -1.0f/sqrt(26.0f); expectedplane.c = 4.0f/sqrt(26.0f); expectedplane.d = 7.0/sqrt(26.0f);
565     D3DXPlaneNormalize(&gotplane, &plane);
566     expect_plane(expectedplane, gotplane);
567     nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 0.0f;
568     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
569     D3DXPlaneNormalize(&gotplane, &nulplane);
570     expect_plane(expectedplane, gotplane);
571     nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
572     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
573     D3DXPlaneNormalize(&gotplane, &nulplane);
574     expect_plane(expectedplane, gotplane);
575
576 /*_______________D3DXPlaneTransform____________*/
577     expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
578     D3DXPlaneTransform(&gotplane,&plane,&mat);
579     expect_plane(expectedplane, gotplane);
580 }
581
582 static void D3X8QuaternionTest(void)
583 {
584     D3DXMATRIX mat;
585     D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, smallq, smallr, q, r, s, t, u;
586     LPD3DXQUATERNION funcpointer;
587     D3DXVECTOR3 axis, expectedvec;
588     FLOAT angle, expected, got, scale, scale2;
589     BOOL expectedbool, gotbool;
590
591     nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
592     q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
593     r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
594     t.x = -1111.0f, t.y = 111.0f; t.z = -11.0f; t.w = 1.0f;
595     u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f;
596     smallq.x = 0.1f; smallq.y = 0.2f; smallq.z= 0.3f; smallq.w = 0.4f;
597     smallr.x = 0.5f; smallr.y = 0.6f; smallr.z= 0.7f; smallr.w = 0.8f;
598
599     scale = 0.3f;
600     scale2 = 0.78f;
601
602 /*_______________D3DXQuaternionBaryCentric________________________*/
603     expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f;
604     D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2);
605     expect_vec4(expectedquat,gotquat);
606
607 /*_______________D3DXQuaternionConjugate________________*/
608     expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
609     D3DXQuaternionConjugate(&gotquat,&q);
610     expect_vec4(expectedquat,gotquat);
611     /* Test the NULL case */
612     funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
613     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
614     funcpointer = D3DXQuaternionConjugate(NULL,NULL);
615     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
616
617 /*_______________D3DXQuaternionDot______________________*/
618     expected = 55.0f;
619     got = D3DXQuaternionDot(&q,&r);
620     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
621     /* Tests the case NULL */
622     expected=0.0f;
623     got = D3DXQuaternionDot(NULL,&r);
624     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
625     expected=0.0f;
626     got = D3DXQuaternionDot(NULL,NULL);
627     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
628
629 /*_______________D3DXQuaternionExp______________________________*/
630     expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f;
631     D3DXQuaternionExp(&gotquat,&q);
632     expect_vec4(expectedquat,gotquat);
633     /* Test the null quaternion */
634     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
635     D3DXQuaternionExp(&gotquat,&nul);
636     expect_vec4(expectedquat,gotquat);
637     /* Test the case where the norm of the quaternion is <1 */
638     Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
639     expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f;
640     D3DXQuaternionExp(&gotquat,&Nq1);
641     expect_vec4(expectedquat,gotquat);
642
643 /*_______________D3DXQuaternionIdentity________________*/
644     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
645     D3DXQuaternionIdentity(&gotquat);
646     expect_vec4(expectedquat,gotquat);
647     /* Test the NULL case */
648     funcpointer = D3DXQuaternionIdentity(NULL);
649     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
650
651 /*_______________D3DXQuaternionInverse________________________*/
652     expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f;
653     D3DXQuaternionInverse(&gotquat,&q);
654     expect_vec4(expectedquat,gotquat);
655     /* test the null quaternion */
656     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
657     D3DXQuaternionInverse(&gotquat,&nul);
658     expect_vec4(expectedquat,gotquat);
659
660 /*_______________D3DXQuaternionIsIdentity________________*/
661     s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
662     expectedbool = TRUE;
663     gotbool = D3DXQuaternionIsIdentity(&s);
664     ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
665     s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
666     expectedbool = FALSE;
667     gotbool = D3DXQuaternionIsIdentity(&q);
668     ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
669     /* Test the NULL case */
670     gotbool = D3DXQuaternionIsIdentity(NULL);
671     ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
672
673 /*_______________D3DXQuaternionLength__________________________*/
674    expected = 11.0f;
675    got = D3DXQuaternionLength(&q);
676    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
677    /* Tests the case NULL */
678     expected=0.0f;
679     got = D3DXQuaternionLength(NULL);
680     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
681
682 /*_______________D3DXQuaternionLengthSq________________________*/
683     expected = 121.0f;
684     got = D3DXQuaternionLengthSq(&q);
685     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
686     /* Tests the case NULL */
687     expected=0.0f;
688     got = D3DXQuaternionLengthSq(NULL);
689     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
690
691 /*_______________D3DXQuaternionLn______________________________*/
692     expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f;
693     D3DXQuaternionLn(&gotquat,&q);
694     expect_vec4(expectedquat,gotquat);
695     expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f;
696     D3DXQuaternionLn(&gotquat,&r);
697     expect_vec4(expectedquat,gotquat);
698     Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f;
699     expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f;
700     D3DXQuaternionLn(&gotquat,&Nq);
701     expect_vec4(expectedquat,gotquat);
702     /* Test the cas where the norm of the quaternion is <1 */
703     Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f;
704     expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f;
705     D3DXQuaternionLn(&gotquat,&Nq1);
706     todo_wine{ expect_vec4(expectedquat,gotquat) };
707
708 /*_______________D3DXQuaternionMultiply________________________*/
709     expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f;
710     D3DXQuaternionMultiply(&gotquat,&q,&r);
711     expect_vec4(expectedquat,gotquat);
712
713 /*_______________D3DXQuaternionNormalize________________________*/
714     expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
715     D3DXQuaternionNormalize(&gotquat,&q);
716     expect_vec4(expectedquat,gotquat);
717     /* Test the nul quaternion */
718     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
719     D3DXQuaternionNormalize(&gotquat,&nul);
720     expect_vec4(expectedquat,gotquat);
721
722 /*_______________D3DXQuaternionRotationAxis___________________*/
723     axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f;
724     angle = D3DX_PI/3.0f;
725     expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f;
726     D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
727     expect_vec4(expectedquat,gotquat);
728  /* Test the nul quaternion */
729     axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f;
730     expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f;
731     D3DXQuaternionRotationAxis(&gotquat,&axis,angle);
732     expect_vec4(expectedquat,gotquat);
733
734 /*_______________D3DXQuaternionRotationMatrix___________________*/
735     /* test when the trace is >0 */
736     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
737     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
738     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
739     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
740     U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f;
741     U(mat).m[3][3] = 48.0f;
742     expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f;
743     D3DXQuaternionRotationMatrix(&gotquat,&mat);
744     expect_vec4(expectedquat,gotquat);
745     /* test the case when the greater element is (2,2) */
746     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
747     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
748     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
749     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
750     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f;
751     U(mat).m[3][3] = 48.0f;
752     expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f;
753     D3DXQuaternionRotationMatrix(&gotquat,&mat);
754     expect_vec4(expectedquat,gotquat);
755     /* test the case when the greater element is (1,1) */
756     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
757     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
758     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
759     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
760     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f;
761     U(mat).m[3][3] = 48.0f;
762     expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f;
763     D3DXQuaternionRotationMatrix(&gotquat,&mat);
764     expect_vec4(expectedquat,gotquat);
765     /* test the case when the trace is near 0 in a matrix which is not a rotation */
766     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
767     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
768     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
769     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
770     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.9f;
771     U(mat).m[3][3] = 48.0f;
772     expectedquat.x = 1.709495f; expectedquat.y = 2.339872f; expectedquat.z = -0.534217f; expectedquat.w = 1.282122f;
773     D3DXQuaternionRotationMatrix(&gotquat,&mat);
774     expect_vec4(expectedquat,gotquat);
775     /* test the case when the trace is 0.49 in a matrix which is not a rotation */
776     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
777     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
778     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
779     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
780     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.51f;
781     U(mat).m[3][3] = 48.0f;
782     expectedquat.x = 1.724923f; expectedquat.y = 2.318944f; expectedquat.z = -0.539039f; expectedquat.w = 1.293692f;
783     D3DXQuaternionRotationMatrix(&gotquat,&mat);
784     expect_vec4(expectedquat,gotquat);
785     /* test the case when the trace is 0.51 in a matrix which is not a rotation */
786     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
787     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
788     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
789     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
790     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.49f;
791     U(mat).m[3][3] = 48.0f;
792     expectedquat.x = 1.725726f; expectedquat.y = 2.317865f; expectedquat.z = -0.539289f; expectedquat.w = 1.294294f;
793     D3DXQuaternionRotationMatrix(&gotquat,&mat);
794     expect_vec4(expectedquat,gotquat);
795     /* test the case when the trace is 0.99 in a matrix which is not a rotation */
796     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
797     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
798     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
799     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
800     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = -0.01f;
801     U(mat).m[3][3] = 48.0f;
802     expectedquat.x = 1.745328f; expectedquat.y = 2.291833f; expectedquat.z = -0.545415f; expectedquat.w = 1.308996f;
803     D3DXQuaternionRotationMatrix(&gotquat,&mat);
804     expect_vec4(expectedquat,gotquat);
805     /* test the case when the trace is 1.0 in a matrix which is not a rotation */
806     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
807     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
808     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
809     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
810     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.0f;
811     U(mat).m[3][3] = 48.0f;
812     expectedquat.x = 1.745743f; expectedquat.y = 2.291288f; expectedquat.z = -0.545545f; expectedquat.w = 1.309307f;
813     D3DXQuaternionRotationMatrix(&gotquat,&mat);
814     expect_vec4(expectedquat,gotquat);
815     /* test the case when the trace is 1.01 in a matrix which is not a rotation */
816     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
817     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
818     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
819     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
820     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.01f;
821     U(mat).m[3][3] = 48.0f;
822     expectedquat.x = 18.408188f; expectedquat.y = 5.970223f; expectedquat.z = -2.985111f; expectedquat.w = 0.502494f;
823     D3DXQuaternionRotationMatrix(&gotquat,&mat);
824     expect_vec4(expectedquat,gotquat);
825     /* test the case when the trace is 1.5 in a matrix which is not a rotation */
826     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
827     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
828     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
829     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
830     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.5f;
831     U(mat).m[3][3] = 48.0f;
832     expectedquat.x = 15.105186f; expectedquat.y = 4.898980f; expectedquat.z = -2.449490f; expectedquat.w = 0.612372f;
833     D3DXQuaternionRotationMatrix(&gotquat,&mat);
834     expect_vec4(expectedquat,gotquat);
835     /* test the case when the trace is 1.7 in a matrix which is not a rotation */
836     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
837     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
838     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
839     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
840     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.70f;
841     U(mat).m[3][3] = 48.0f;
842     expectedquat.x = 14.188852f; expectedquat.y = 4.601790f; expectedquat.z = -2.300895f; expectedquat.w = 0.651920f;
843     D3DXQuaternionRotationMatrix(&gotquat,&mat);
844     expect_vec4(expectedquat,gotquat);
845     /* test the case when the trace is 1.99 in a matrix which is not a rotation */
846     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
847     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
848     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
849     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
850     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 0.99f;
851     U(mat).m[3][3] = 48.0f;
852     expectedquat.x = 13.114303f; expectedquat.y = 4.253287f; expectedquat.z = -2.126644f; expectedquat.w = 0.705337f;
853     D3DXQuaternionRotationMatrix(&gotquat,&mat);
854     expect_vec4(expectedquat,gotquat);
855     /* test the case when the trace is 2.0 in a matrix which is not a rotation */
856     U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
857     U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f;
858     U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f;
859     U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f;
860     U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 10.0f; U(mat).m[2][2] = 2.0f;
861     U(mat).m[3][3] = 48.0f;
862     expectedquat.x = 10.680980f; expectedquat.y = 3.464102f; expectedquat.z = -1.732051f; expectedquat.w = 0.866025f;
863     D3DXQuaternionRotationMatrix(&gotquat,&mat);
864     expect_vec4(expectedquat,gotquat);
865
866 /*_______________D3DXQuaternionRotationYawPitchRoll__________*/
867     expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f;
868     D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f);
869     expect_vec4(expectedquat,gotquat);
870
871 /*_______________D3DXQuaternionSlerp________________________*/
872     expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f;
873     D3DXQuaternionSlerp(&gotquat,&q,&r,scale);
874     expect_vec4(expectedquat,gotquat);
875     expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f;
876     D3DXQuaternionSlerp(&gotquat,&q,&t,scale);
877     expect_vec4(expectedquat,gotquat);
878     expectedquat.x = 0.239485f; expectedquat.y = 0.346580f; expectedquat.z = 0.453676f; expectedquat.w = 0.560772f;
879     D3DXQuaternionSlerp(&gotquat,&smallq,&smallr,scale);
880     expect_vec4(expectedquat,gotquat);
881
882 /*_______________D3DXQuaternionSquad________________________*/
883     expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f;
884     D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale);
885     expect_vec4(expectedquat,gotquat);
886
887 /*_______________D3DXQuaternionToAxisAngle__________________*/
888     Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f;
889     expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
890     expected = 2.197869f;
891     D3DXQuaternionToAxisAngle(&Nq,&axis,&angle);
892     expect_vec3(expectedvec,axis);
893     ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
894     /* Test if |w|>1.0f */
895     expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f;
896     expected = 0.0f;
897     D3DXQuaternionToAxisAngle(&q,&axis,&angle);
898     expect_vec3(expectedvec,axis);
899     ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
900     /* Test the null quaternion */
901     expectedvec.x = 1.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
902     expected = 0.0f;
903     D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
904     expect_vec3(expectedvec,axis);
905     ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
906 }
907
908 static void D3X8Vector2Test(void)
909 {
910     D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
911     LPD3DXVECTOR2 funcpointer;
912     D3DXVECTOR4 expectedtrans, gottrans;
913     D3DXMATRIX mat;
914     FLOAT coeff1, coeff2, expected, got, scale;
915
916     nul.x = 0.0f; nul.y = 0.0f;
917     u.x = 3.0f; u.y = 4.0f;
918     v.x = -7.0f; v.y = 9.0f;
919     w.x = 4.0f; w.y = -3.0f;
920     x.x = 2.0f; x.y = -11.0f;
921
922     U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
923     U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
924     U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
925     U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
926
927     coeff1 = 2.0f; coeff2 = 5.0f;
928     scale = -6.5f;
929
930 /*_______________D3DXVec2Add__________________________*/
931     expectedvec.x = -4.0f; expectedvec.y = 13.0f;
932     D3DXVec2Add(&gotvec,&u,&v);
933     expect_vec(expectedvec,gotvec);
934     /* Tests the case NULL */
935     funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
936     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
937     funcpointer = D3DXVec2Add(NULL,NULL,NULL);
938     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
939
940 /*_______________D3DXVec2BaryCentric___________________*/
941     expectedvec.x = -12.0f; expectedvec.y = -21.0f;
942     D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
943     expect_vec(expectedvec,gotvec);
944
945 /*_______________D3DXVec2CatmullRom____________________*/
946     expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
947     D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
948     expect_vec(expectedvec,gotvec);
949
950 /*_______________D3DXVec2CCW__________________________*/
951    expected = 55.0f;
952    got = D3DXVec2CCW(&u,&v);
953    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
954    /* Tests the case NULL */
955     expected=0.0f;
956     got = D3DXVec2CCW(NULL,&v);
957     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
958     expected=0.0f;
959     got = D3DXVec2CCW(NULL,NULL);
960     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
961
962 /*_______________D3DXVec2Dot__________________________*/
963     expected = 15.0f;
964     got = D3DXVec2Dot(&u,&v);
965     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
966     /* Tests the case NULL */
967     expected=0.0f;
968     got = D3DXVec2Dot(NULL,&v);
969     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
970     expected=0.0f;
971     got = D3DXVec2Dot(NULL,NULL);
972     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
973
974 /*_______________D3DXVec2Hermite__________________________*/
975     expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
976     D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
977     expect_vec(expectedvec,gotvec);
978
979 /*_______________D3DXVec2Length__________________________*/
980    expected = 5.0f;
981    got = D3DXVec2Length(&u);
982    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
983    /* Tests the case NULL */
984     expected=0.0f;
985     got = D3DXVec2Length(NULL);
986     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
987
988 /*_______________D3DXVec2LengthSq________________________*/
989    expected = 25.0f;
990    got = D3DXVec2LengthSq(&u);
991    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
992    /* Tests the case NULL */
993     expected=0.0f;
994     got = D3DXVec2LengthSq(NULL);
995     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
996
997 /*_______________D3DXVec2Lerp__________________________*/
998    expectedvec.x = 68.0f; expectedvec.y = -28.5f;
999    D3DXVec2Lerp(&gotvec,&u,&v,scale);
1000    expect_vec(expectedvec,gotvec);
1001    /* Tests the case NULL */
1002     funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
1003     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1004     funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
1005     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1006
1007 /*_______________D3DXVec2Maximize__________________________*/
1008    expectedvec.x = 3.0f; expectedvec.y = 9.0f;
1009    D3DXVec2Maximize(&gotvec,&u,&v);
1010    expect_vec(expectedvec,gotvec);
1011    /* Tests the case NULL */
1012     funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
1013     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1014     funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
1015     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1016
1017 /*_______________D3DXVec2Minimize__________________________*/
1018     expectedvec.x = -7.0f; expectedvec.y = 4.0f;
1019     D3DXVec2Minimize(&gotvec,&u,&v);
1020     expect_vec(expectedvec,gotvec);
1021     /* Tests the case NULL */
1022     funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
1023     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1024     funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
1025     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1026
1027 /*_______________D3DXVec2Normalize_________________________*/
1028     expectedvec.x = 0.6f; expectedvec.y = 0.8f;
1029     D3DXVec2Normalize(&gotvec,&u);
1030     expect_vec(expectedvec,gotvec);
1031     /* Test the nul vector */
1032     expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1033     D3DXVec2Normalize(&gotvec,&nul);
1034     expect_vec(expectedvec,gotvec);
1035
1036 /*_______________D3DXVec2Scale____________________________*/
1037     expectedvec.x = -19.5f; expectedvec.y = -26.0f;
1038     D3DXVec2Scale(&gotvec,&u,scale);
1039     expect_vec(expectedvec,gotvec);
1040     /* Tests the case NULL */
1041     funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
1042     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1043     funcpointer = D3DXVec2Scale(NULL,NULL,scale);
1044     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1045
1046 /*_______________D3DXVec2Subtract__________________________*/
1047    expectedvec.x = 10.0f; expectedvec.y = -5.0f;
1048    D3DXVec2Subtract(&gotvec,&u,&v);
1049    expect_vec(expectedvec,gotvec);
1050    /* Tests the case NULL */
1051     funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
1052     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1053     funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
1054     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1055
1056 /*_______________D3DXVec2Transform_______________________*/
1057     expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
1058     D3DXVec2Transform(&gottrans,&u,&mat);
1059     expect_vec4(expectedtrans,gottrans);
1060
1061 /*_______________D3DXVec2TransformCoord_______________________*/
1062     expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
1063     D3DXVec2TransformCoord(&gotvec,&u,&mat);
1064     expect_vec(expectedvec,gotvec);
1065     /* Test the nul projected vector */
1066     nulproj.x = -2.0f; nulproj.y = -1.0f;
1067     expectedvec.x = 0.0f; expectedvec.y = 0.0f;
1068     D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
1069     expect_vec(expectedvec,gotvec);
1070
1071  /*_______________D3DXVec2TransformNormal______________________*/
1072     expectedvec.x = 23.0f; expectedvec.y = 30.0f;
1073     D3DXVec2TransformNormal(&gotvec,&u,&mat);
1074     expect_vec(expectedvec,gotvec);
1075 }
1076
1077 static void D3X8Vector3Test(void)
1078 {
1079     D3DVIEWPORT8 viewport;
1080     D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
1081     LPD3DXVECTOR3 funcpointer;
1082     D3DXVECTOR4 expectedtrans, gottrans;
1083     D3DXMATRIX mat, projection, view, world;
1084     FLOAT coeff1, coeff2, expected, got, scale;
1085
1086     nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
1087     u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
1088     v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
1089     w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
1090     x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
1091
1092     viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
1093     viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
1094
1095     U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
1096     U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
1097     U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
1098     U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
1099
1100     U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f;
1101     U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f;
1102     U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f;
1103     U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f;
1104     U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f;
1105     U(view).m[3][3] = -40.0f;
1106
1107     U(world).m[0][0] = 21.0f; U(world).m[0][1] = 2.0f; U(world).m[0][2] = 3.0f; U(world).m[0][3] = 4.0;
1108     U(world).m[1][0] = 5.0f; U(world).m[1][1] = 23.0f; U(world).m[1][2] = 7.0f; U(world).m[1][3] = 8.0f;
1109     U(world).m[2][0] = -8.0f; U(world).m[2][1] = -7.0f; U(world).m[2][2] = 25.0f; U(world).m[2][3] = -5.0f;
1110     U(world).m[3][0] = -4.0f; U(world).m[3][1] = -3.0f; U(world).m[3][2] = -2.0f; U(world).m[3][3] = 27.0f;
1111
1112     coeff1 = 2.0f; coeff2 = 5.0f;
1113     scale = -6.5f;
1114
1115 /*_______________D3DXVec3Add__________________________*/
1116     expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
1117     D3DXVec3Add(&gotvec,&u,&v);
1118     expect_vec3(expectedvec,gotvec);
1119     /* Tests the case NULL */
1120     funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
1121     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1122     funcpointer = D3DXVec3Add(NULL,NULL,NULL);
1123     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1124
1125 /*_______________D3DXVec3BaryCentric___________________*/
1126     expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
1127     D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1128
1129     expect_vec3(expectedvec,gotvec);
1130
1131 /*_______________D3DXVec3CatmullRom____________________*/
1132     expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
1133     D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1134     expect_vec3(expectedvec,gotvec);
1135
1136 /*_______________D3DXVec3Cross________________________*/
1137     expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -39.0f;
1138     D3DXVec3Cross(&gotvec,&u,&v);
1139     expect_vec3(expectedvec,gotvec);
1140     /* Tests the case NULL */
1141     funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
1142     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1143     funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
1144     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1145
1146 /*_______________D3DXVec3Dot__________________________*/
1147     expected = -8.0f;
1148     got = D3DXVec3Dot(&u,&v);
1149     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1150     /* Tests the case NULL */
1151     expected=0.0f;
1152     got = D3DXVec3Dot(NULL,&v);
1153     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1154     expected=0.0f;
1155     got = D3DXVec3Dot(NULL,NULL);
1156     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1157
1158 /*_______________D3DXVec3Hermite__________________________*/
1159     expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
1160     D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
1161     expect_vec3(expectedvec,gotvec);
1162
1163 /*_______________D3DXVec3Length__________________________*/
1164    expected = 11.0f;
1165    got = D3DXVec3Length(&u);
1166    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1167    /* Tests the case NULL */
1168     expected=0.0f;
1169     got = D3DXVec3Length(NULL);
1170     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1171
1172 /*_______________D3DXVec3LengthSq________________________*/
1173     expected = 121.0f;
1174     got = D3DXVec3LengthSq(&u);
1175     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1176    /* Tests the case NULL */
1177     expected=0.0f;
1178     got = D3DXVec3LengthSq(NULL);
1179     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1180
1181 /*_______________D3DXVec3Lerp__________________________*/
1182     expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
1183     D3DXVec3Lerp(&gotvec,&u,&v,scale);
1184     expect_vec3(expectedvec,gotvec);
1185     /* Tests the case NULL */
1186     funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
1187     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1188     funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
1189     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1190
1191 /*_______________D3DXVec3Maximize__________________________*/
1192     expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
1193     D3DXVec3Maximize(&gotvec,&u,&v);
1194     expect_vec3(expectedvec,gotvec);
1195     /* Tests the case NULL */
1196     funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
1197     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1198     funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
1199     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1200
1201 /*_______________D3DXVec3Minimize__________________________*/
1202     expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
1203     D3DXVec3Minimize(&gotvec,&u,&v);
1204     expect_vec3(expectedvec,gotvec);
1205     /* Tests the case NULL */
1206     funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
1207     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1208     funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
1209     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1210
1211 /*_______________D3DXVec3Normalize_________________________*/
1212     expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
1213     D3DXVec3Normalize(&gotvec,&u);
1214     expect_vec3(expectedvec,gotvec);
1215     /* Test the nul vector */
1216     expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1217     D3DXVec3Normalize(&gotvec,&nul);
1218     expect_vec3(expectedvec,gotvec);
1219
1220 /*_______________D3DXVec3Project_________________________*/
1221     expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
1222     D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1223     D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
1224     expect_vec3(expectedvec,gotvec);
1225
1226 /*_______________D3DXVec3Scale____________________________*/
1227     expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
1228     D3DXVec3Scale(&gotvec,&u,scale);
1229     expect_vec3(expectedvec,gotvec);
1230     /* Tests the case NULL */
1231     funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
1232     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1233     funcpointer = D3DXVec3Scale(NULL,NULL,scale);
1234     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1235
1236 /*_______________D3DXVec3Subtract_______________________*/
1237     expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
1238     D3DXVec3Subtract(&gotvec,&u,&v);
1239     expect_vec3(expectedvec,gotvec);
1240     /* Tests the case NULL */
1241     funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
1242     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1243     funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
1244     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1245
1246 /*_______________D3DXVec3Transform_______________________*/
1247     expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
1248     D3DXVec3Transform(&gottrans,&u,&mat);
1249     expect_vec4(expectedtrans,gottrans);
1250
1251 /*_______________D3DXVec3TransformCoord_______________________*/
1252     expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
1253     D3DXVec3TransformCoord(&gotvec,&u,&mat);
1254     expect_vec3(expectedvec,gotvec);
1255     /* Test the nul projected vector */
1256     nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
1257     expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
1258     D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
1259     expect_vec3(expectedvec,gotvec);
1260
1261 /*_______________D3DXVec3TransformNormal______________________*/
1262     expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
1263     D3DXVec3TransformNormal(&gotvec,&u,&mat);
1264     expect_vec3(expectedvec,gotvec);
1265
1266 /*_______________D3DXVec3Unproject_________________________*/
1267     expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
1268     D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
1269     D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
1270     expect_vec3(expectedvec,gotvec);
1271 }
1272
1273 static void D3X8Vector4Test(void)
1274 {
1275     D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
1276     LPD3DXVECTOR4 funcpointer;
1277     D3DXVECTOR4 expectedtrans, gottrans;
1278     D3DXMATRIX mat;
1279     FLOAT coeff1, coeff2, expected, got, scale;
1280
1281     nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
1282     u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
1283     v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
1284     w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
1285     x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
1286
1287     U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
1288     U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
1289     U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
1290     U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
1291
1292     coeff1 = 2.0f; coeff2 = 5.0;
1293     scale = -6.5f;
1294
1295 /*_______________D3DXVec4Add__________________________*/
1296     expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
1297     D3DXVec4Add(&gotvec,&u,&v);
1298     expect_vec4(expectedvec,gotvec);
1299     /* Tests the case NULL */
1300     funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
1301     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1302     funcpointer = D3DXVec4Add(NULL,NULL,NULL);
1303     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1304
1305 /*_______________D3DXVec4BaryCentric____________________*/
1306     expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z =  -44.0f; expectedvec.w = -41.0f;
1307     D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
1308     expect_vec4(expectedvec,gotvec);
1309
1310 /*_______________D3DXVec4CatmullRom____________________*/
1311     expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
1312     D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
1313     expect_vec4(expectedvec,gotvec);
1314
1315 /*_______________D3DXVec4Cross_________________________*/
1316     expectedvec.x = 390.0f; expectedvec.y = -393.0f; expectedvec.z = -316.0f; expectedvec.w = 166.0f;
1317     D3DXVec4Cross(&gotvec,&u,&v,&w);
1318     expect_vec4(expectedvec,gotvec);
1319
1320 /*_______________D3DXVec4Dot__________________________*/
1321     expected = 55.0f;
1322     got = D3DXVec4Dot(&u,&v);
1323     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1324     /* Tests the case NULL */
1325     expected=0.0f;
1326     got = D3DXVec4Dot(NULL,&v);
1327     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1328     expected=0.0f;
1329     got = D3DXVec4Dot(NULL,NULL);
1330     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1331
1332 /*_______________D3DXVec4Hermite_________________________*/
1333     expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
1334     D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
1335     expect_vec4(expectedvec,gotvec);
1336
1337 /*_______________D3DXVec4Length__________________________*/
1338    expected = 11.0f;
1339    got = D3DXVec4Length(&u);
1340    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1341    /* Tests the case NULL */
1342     expected=0.0f;
1343     got = D3DXVec4Length(NULL);
1344     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1345
1346 /*_______________D3DXVec4LengthSq________________________*/
1347     expected = 121.0f;
1348     got = D3DXVec4LengthSq(&u);
1349     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1350     /* Tests the case NULL */
1351     expected=0.0f;
1352     got = D3DXVec4LengthSq(NULL);
1353     ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
1354
1355 /*_______________D3DXVec4Lerp__________________________*/
1356     expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5;  expectedvec.w = 29.5;
1357     D3DXVec4Lerp(&gotvec,&u,&v,scale);
1358     expect_vec4(expectedvec,gotvec);
1359     /* Tests the case NULL */
1360     funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
1361     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1362     funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
1363     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1364
1365 /*_______________D3DXVec4Maximize__________________________*/
1366     expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
1367     D3DXVec4Maximize(&gotvec,&u,&v);
1368     expect_vec4(expectedvec,gotvec);
1369     /* Tests the case NULL */
1370     funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
1371     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1372     funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
1373     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1374
1375 /*_______________D3DXVec4Minimize__________________________*/
1376     expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
1377     D3DXVec4Minimize(&gotvec,&u,&v);
1378     expect_vec4(expectedvec,gotvec);
1379     /* Tests the case NULL */
1380     funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
1381     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1382     funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
1383     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1384
1385 /*_______________D3DXVec4Normalize_________________________*/
1386     expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
1387     D3DXVec4Normalize(&gotvec,&u);
1388     expect_vec4(expectedvec,gotvec);
1389     /* Test the nul vector */
1390     expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
1391     D3DXVec4Normalize(&gotvec,&nul);
1392     expect_vec4(expectedvec,gotvec);
1393
1394 /*_______________D3DXVec4Scale____________________________*/
1395     expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
1396     D3DXVec4Scale(&gotvec,&u,scale);
1397     expect_vec4(expectedvec,gotvec);
1398     /* Tests the case NULL */
1399     funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
1400     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1401     funcpointer = D3DXVec4Scale(NULL,NULL,scale);
1402     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1403
1404 /*_______________D3DXVec4Subtract__________________________*/
1405     expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
1406     D3DXVec4Subtract(&gotvec,&u,&v);
1407     expect_vec4(expectedvec,gotvec);
1408     /* Tests the case NULL */
1409     funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
1410     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1411     funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
1412     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
1413
1414 /*_______________D3DXVec4Transform_______________________*/
1415     expectedtrans.x = 177.0f; expectedtrans.y = 194.0f; expectedtrans.z = 211.0f; expectedtrans.w = 228.0f;
1416     D3DXVec4Transform(&gottrans,&u,&mat);
1417     expect_vec4(expectedtrans,gottrans);
1418 }
1419
1420 static void test_matrix_stack(void)
1421 {
1422     ID3DXMatrixStack *stack;
1423     ULONG refcount;
1424     HRESULT hr;
1425
1426     const D3DXMATRIX mat1 = {{{
1427          1.0f,  2.0f,  3.0f,  4.0f,
1428          5.0f,  6.0f,  7.0f,  8.0f,
1429          9.0f, 10.0f, 11.0f, 12.0f,
1430         13.0f, 14.0f, 15.0f, 16.0f
1431     }}};
1432
1433     const D3DXMATRIX mat2 = {{{
1434         17.0f, 18.0f, 19.0f, 20.0f,
1435         21.0f, 22.0f, 23.0f, 24.0f,
1436         25.0f, 26.0f, 27.0f, 28.0f,
1437         29.0f, 30.0f, 31.0f, 32.0f
1438     }}};
1439
1440     hr = D3DXCreateMatrixStack(0, &stack);
1441     ok(SUCCEEDED(hr), "Failed to create a matrix stack, hr %#x\n", hr);
1442     if (FAILED(hr)) return;
1443
1444     ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)),
1445             "The top of an empty matrix stack should be an identity matrix\n");
1446
1447     hr = ID3DXMatrixStack_Pop(stack);
1448     ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1449
1450     hr = ID3DXMatrixStack_Push(stack);
1451     ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1452     ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1453
1454     hr = ID3DXMatrixStack_Push(stack);
1455     ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1456
1457     hr = ID3DXMatrixStack_LoadMatrix(stack, NULL);
1458     ok(hr == D3DERR_INVALIDCALL, "LoadMatrix returned %#x, expected D3DERR_INVALIDCALL\n", hr);
1459
1460     hr = ID3DXMatrixStack_LoadMatrix(stack, &mat1);
1461     ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
1462     expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1463
1464     hr = ID3DXMatrixStack_Push(stack);
1465     ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1466     expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1467
1468     hr = ID3DXMatrixStack_LoadMatrix(stack, &mat2);
1469     ok(SUCCEEDED(hr), "LoadMatrix failed, hr %#x\n", hr);
1470     expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1471
1472     hr = ID3DXMatrixStack_Push(stack);
1473     ok(SUCCEEDED(hr), "Push failed, hr %#x\n", hr);
1474     expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1475
1476     hr = ID3DXMatrixStack_LoadIdentity(stack);
1477     ok(SUCCEEDED(hr), "LoadIdentity failed, hr %#x\n", hr);
1478     ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1479
1480     hr = ID3DXMatrixStack_Pop(stack);
1481     ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1482     expect_mat(&mat2, ID3DXMatrixStack_GetTop(stack));
1483
1484     hr = ID3DXMatrixStack_Pop(stack);
1485     ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1486     expect_mat(&mat1, ID3DXMatrixStack_GetTop(stack));
1487
1488     hr = ID3DXMatrixStack_Pop(stack);
1489     ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1490     ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1491
1492     hr = ID3DXMatrixStack_Pop(stack);
1493     ok(SUCCEEDED(hr), "Pop failed, hr %#x\n", hr);
1494     ok(D3DXMatrixIsIdentity(ID3DXMatrixStack_GetTop(stack)), "The top should be an identity matrix\n");
1495
1496     hr = ID3DXMatrixStack_MultMatrix(stack, NULL);
1497     ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1498
1499     hr = ID3DXMatrixStack_MultMatrixLocal(stack, NULL);
1500     ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1501
1502     hr = ID3DXMatrixStack_RotateAxis(stack, NULL, 2.0f);
1503     ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1504
1505     hr = ID3DXMatrixStack_RotateAxisLocal(stack, NULL, 2.0f);
1506     ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
1507
1508     refcount = ID3DXMatrixStack_Release(stack);
1509     ok(!refcount, "Matrix stack has %u references left.\n", refcount);
1510 }
1511
1512 START_TEST(math)
1513 {
1514     D3DXColorTest();
1515     D3DXFresnelTest();
1516     D3DXMatrixTest();
1517     D3DXPlaneTest();
1518     D3X8QuaternionTest();
1519     D3X8Vector2Test();
1520     D3X8Vector3Test();
1521     D3X8Vector4Test();
1522     test_matrix_stack();
1523 }