2 * Copyright 2007 David Adam
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.
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.
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
22 #include "wine/test.h"
24 #define admitted_error 0.00001f
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);
28 #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);
30 #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);
32 #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);
34 static void D3DXColorTest(void)
36 D3DXCOLOR color, color1, color2, expected, got;
37 LPD3DXCOLOR funcpointer;
40 color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f;
41 color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f;
42 color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f;
45 /*_______________D3DXColorAdd________________*/
46 expected.r = 0.9f; expected.g = 1.05f; expected.b = 0.99f, expected.a = 0.93f;
47 D3DXColorAdd(&got,&color1,&color2);
48 expect_color(expected,got);
49 /* Test the NULL case */
50 funcpointer = D3DXColorAdd(&got,NULL,&color2);
51 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
52 funcpointer = D3DXColorAdd(NULL,NULL,&color2);
53 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
54 funcpointer = D3DXColorAdd(NULL,NULL,NULL);
55 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
57 /*_______________D3DXColorLerp________________*/
58 expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f;
59 D3DXColorLerp(&got,&color,&color1,scale);
60 expect_color(expected,got);
61 /* Test the NULL case */
62 funcpointer = D3DXColorLerp(&got,NULL,&color1,scale);
63 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
64 funcpointer = D3DXColorLerp(NULL,NULL,&color1,scale);
65 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
66 funcpointer = D3DXColorLerp(NULL,NULL,NULL,scale);
67 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
69 /*_______________D3DXColorModulate________________*/
70 expected.r = 0.18f; expected.g = 0.275f; expected.b = 0.1748f; expected.a = 0.0902f;
71 D3DXColorModulate(&got,&color1,&color2);
72 expect_color(expected,got);
73 /* Test the NULL case */
74 funcpointer = D3DXColorModulate(&got,NULL,&color2);
75 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
76 funcpointer = D3DXColorModulate(NULL,NULL,&color2);
77 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
78 funcpointer = D3DXColorModulate(NULL,NULL,NULL);
79 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
81 /*_______________D3DXColorNegative________________*/
82 expected.r = 0.8f; expected.g = 0.25f; expected.b = 0.59f; expected.a = 0.93f;
83 D3DXColorNegative(&got,&color);
84 expect_color(got,expected);
85 /* Test the greater than 1 case */
86 color1.r = 0.2f; color1.g = 1.75f; color1.b = 0.41f; color1.a = 0.93f;
87 expected.r = 0.8f; expected.g = -0.75f; expected.b = 0.59f; expected.a = 0.93f;
88 D3DXColorNegative(&got,&color1);
89 expect_color(got,expected);
90 /* Test the negative case */
91 color1.r = 0.2f; color1.g = -0.75f; color1.b = 0.41f; color1.a = 0.93f;
92 expected.r = 0.8f; expected.g = 1.75f; expected.b = 0.59f; expected.a = 0.93f;
93 D3DXColorNegative(&got,&color1);
94 expect_color(got,expected);
95 /* Test the NULL case */
96 funcpointer = D3DXColorNegative(&got,NULL);
97 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
98 funcpointer = D3DXColorNegative(NULL,NULL);
99 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
101 /*_______________D3DXColorScale________________*/
102 expected.r = 0.06f; expected.g = 0.225f; expected.b = 0.123f; expected.a = 0.279f;
103 D3DXColorScale(&got,&color,scale);
104 expect_color(expected,got);
105 /* Test the NULL case */
106 funcpointer = D3DXColorScale(&got,NULL,scale);
107 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
108 funcpointer = D3DXColorScale(NULL,NULL,scale);
109 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
111 /*_______________D3DXColorSubtract_______________*/
112 expected.r = -0.1f; expected.g = 0.25f; expected.b = -0.35f, expected.a = 0.82f;
113 D3DXColorSubtract(&got,&color,&color2);
114 expect_color(expected,got);
115 /* Test the NULL case */
116 funcpointer = D3DXColorSubtract(&got,NULL,&color2);
117 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
118 funcpointer = D3DXColorSubtract(NULL,NULL,&color2);
119 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
120 funcpointer = D3DXColorSubtract(NULL,NULL,NULL);
121 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
124 static void D3DXMatrixTest(void)
129 /*____________D3DXMatrixIsIdentity______________*/
130 U(mat).m[0][1] = 0.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f;
131 U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 0.0f; U(mat).m[1][3] = 0.0f;
132 U(mat).m[2][0] = 0.0f; U(mat).m[2][1] = 0.0f; U(mat).m[2][3] = 0.0f;
133 U(mat).m[3][0] = 0.0f; U(mat).m[3][1] = 0.0f; U(mat).m[3][2] = 0.0f;
134 U(mat).m[0][0] = 1.0f; U(mat).m[1][1] = 1.0f; U(mat).m[2][2] = 1.0f;
135 U(mat).m[3][3] = 1.0f;
137 got = D3DXMatrixIsIdentity(&mat);
138 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
139 D3DXMatrixIdentity(&mat);
141 got = D3DXMatrixIsIdentity(&mat);
142 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
143 /* Test the NULL case */
145 got = D3DXMatrixIsIdentity(NULL);
146 ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
149 static void D3DXPlaneTest(void)
155 plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f;
156 vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f;
158 /*_______________D3DXPlaneDot________________*/
160 got = D3DXPlaneDot(&plane,&vec),
161 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
163 got = D3DXPlaneDot(NULL,&vec),
164 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
166 got = D3DXPlaneDot(NULL,NULL),
167 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
169 /*_______________D3DXPlaneDotCoord________________*/
171 got = D3DXPlaneDotCoord(&plane,&vec),
172 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
174 got = D3DXPlaneDotCoord(NULL,&vec),
175 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
177 got = D3DXPlaneDotCoord(NULL,NULL),
178 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
180 /*_______________D3DXPlaneDotNormal______________*/
182 got = D3DXPlaneDotNormal(&plane,&vec),
183 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
185 got = D3DXPlaneDotNormal(NULL,&vec),
186 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
188 got = D3DXPlaneDotNormal(NULL,NULL),
189 ok( expected == got, "Expected : %f, Got : %f\n",expected, got);
192 static void D3X8QuaternionTest(void)
194 D3DXQUATERNION expectedquat, gotquat, nul, q, r, s;
195 LPD3DXQUATERNION funcpointer;
197 BOOL expectedbool, gotbool;
199 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
200 q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
201 r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
203 /*_______________D3DXQuaternionConjugate________________*/
204 expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f;
205 D3DXQuaternionConjugate(&gotquat,&q);
206 expect_vec4(expectedquat,gotquat);
207 /* Test the NULL case */
208 funcpointer = D3DXQuaternionConjugate(&gotquat,NULL);
209 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
210 funcpointer = D3DXQuaternionConjugate(NULL,NULL);
211 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
213 /*_______________D3DXQuaternionDot______________________*/
215 got = D3DXQuaternionDot(&q,&r);
216 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
217 /* Tests the case NULL */
219 got = D3DXQuaternionDot(NULL,&r);
220 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
222 got = D3DXQuaternionDot(NULL,NULL);
223 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
225 /*_______________D3DXQuaternionIdentity________________*/
226 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f;
227 D3DXQuaternionIdentity(&gotquat);
228 expect_vec4(expectedquat,gotquat);
229 /* Test the NULL case */
230 funcpointer = D3DXQuaternionIdentity(NULL);
231 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
233 /*_______________D3DXQuaternionIsIdentity________________*/
234 s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
236 gotbool = D3DXQuaternionIsIdentity(&s);
237 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
238 s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
239 expectedbool = FALSE;
240 gotbool = D3DXQuaternionIsIdentity(&q);
241 ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
242 /* Test the NULL case */
243 gotbool = D3DXQuaternionIsIdentity(NULL);
244 ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
246 /*_______________D3DXQuaternionLength__________________________*/
248 got = D3DXQuaternionLength(&q);
249 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
250 /* Tests the case NULL */
252 got = D3DXQuaternionLength(NULL);
253 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
255 /*_______________D3DXQuaternionLengthSq________________________*/
257 got = D3DXQuaternionLengthSq(&q);
258 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
259 /* Tests the case NULL */
261 got = D3DXQuaternionLengthSq(NULL);
262 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
264 /*_______________D3DXQuaternionNormalize________________________*/
265 expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f;
266 D3DXQuaternionNormalize(&gotquat,&q);
267 expect_vec4(expectedquat,gotquat);
268 /* Test the nul quaternion */
269 expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f;
270 D3DXQuaternionNormalize(&gotquat,&nul);
271 expect_vec4(expectedquat,gotquat);
274 static void D3X8Vector2Test(void)
276 D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w, x;
277 LPD3DXVECTOR2 funcpointer;
278 FLOAT coeff1, coeff2, expected, got, scale;
280 nul.x = 0.0f; nul.y = 0.0f;
281 u.x = 3.0f; u.y = 4.0f;
282 v.x = -7.0f; v.y = 9.0f;
283 w.x = 4.0f; w.y = -3.0f;
284 x.x = 2.0f; x.y = -11.0f;
286 coeff1 = 2.0f; coeff2 = 5.0f;
289 /*_______________D3DXVec2Add__________________________*/
290 expectedvec.x = -4.0f; expectedvec.y = 13.0f;
291 D3DXVec2Add(&gotvec,&u,&v);
292 expect_vec(expectedvec,gotvec);
293 /* Tests the case NULL */
294 funcpointer = D3DXVec2Add(&gotvec,NULL,&v);
295 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
296 funcpointer = D3DXVec2Add(NULL,NULL,NULL);
297 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
299 /*_______________D3DXVec2BaryCentric___________________*/
300 expectedvec.x = -12.0f; expectedvec.y = -21.0f;
301 D3DXVec2BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
302 expect_vec(expectedvec,gotvec);
304 /*_______________D3DXVec2CatmullRom____________________*/
305 expectedvec.x = 5820.25f; expectedvec.y = -3654.5625f;
306 D3DXVec2CatmullRom(&gotvec,&u,&v,&w,&x,scale);
307 expect_vec(expectedvec,gotvec);
309 /*_______________D3DXVec2CCW__________________________*/
311 got = D3DXVec2CCW(&u,&v);
312 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
313 /* Tests the case NULL */
315 got = D3DXVec2CCW(NULL,&v);
316 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
318 got = D3DXVec2CCW(NULL,NULL);
319 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
321 /*_______________D3DXVec2Dot__________________________*/
323 got = D3DXVec2Dot(&u,&v);
324 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
325 /* Tests the case NULL */
327 got = D3DXVec2Dot(NULL,&v);
328 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
330 got = D3DXVec2Dot(NULL,NULL);
331 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
333 /*_______________D3DXVec2Hermite__________________________*/
334 expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
335 D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
336 expect_vec(expectedvec,gotvec);
338 /*_______________D3DXVec2Length__________________________*/
340 got = D3DXVec2Length(&u);
341 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
342 /* Tests the case NULL */
344 got = D3DXVec2Length(NULL);
345 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
347 /*_______________D3DXVec2LengthSq________________________*/
349 got = D3DXVec2LengthSq(&u);
350 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
351 /* Tests the case NULL */
353 got = D3DXVec2LengthSq(NULL);
354 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
356 /*_______________D3DXVec2Lerp__________________________*/
357 expectedvec.x = 68.0f; expectedvec.y = -28.5f;
358 D3DXVec2Lerp(&gotvec,&u,&v,scale);
359 expect_vec(expectedvec,gotvec);
360 /* Tests the case NULL */
361 funcpointer = D3DXVec2Lerp(&gotvec,NULL,&v,scale);
362 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
363 funcpointer = D3DXVec2Lerp(NULL,NULL,NULL,scale);
364 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
366 /*_______________D3DXVec2Maximize__________________________*/
367 expectedvec.x = 3.0f; expectedvec.y = 9.0f;
368 D3DXVec2Maximize(&gotvec,&u,&v);
369 expect_vec(expectedvec,gotvec);
370 /* Tests the case NULL */
371 funcpointer = D3DXVec2Maximize(&gotvec,NULL,&v);
372 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
373 funcpointer = D3DXVec2Maximize(NULL,NULL,NULL);
374 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
376 /*_______________D3DXVec2Minimize__________________________*/
377 expectedvec.x = -7.0f; expectedvec.y = 4.0f;
378 D3DXVec2Minimize(&gotvec,&u,&v);
379 expect_vec(expectedvec,gotvec);
380 /* Tests the case NULL */
381 funcpointer = D3DXVec2Minimize(&gotvec,NULL,&v);
382 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
383 funcpointer = D3DXVec2Minimize(NULL,NULL,NULL);
384 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
386 /*_______________D3DXVec2Normalize_________________________*/
387 expectedvec.x = 0.6f; expectedvec.y = 0.8f;
388 D3DXVec2Normalize(&gotvec,&u);
389 expect_vec(expectedvec,gotvec);
390 /* Test the nul vector */
391 expectedvec.x = 0.0f; expectedvec.y = 0.0f;
392 D3DXVec2Normalize(&gotvec,&nul);
393 expect_vec(expectedvec,gotvec);
395 /*_______________D3DXVec2Scale____________________________*/
396 expectedvec.x = -19.5f; expectedvec.y = -26.0f;
397 D3DXVec2Scale(&gotvec,&u,scale);
398 expect_vec(expectedvec,gotvec);
399 /* Tests the case NULL */
400 funcpointer = D3DXVec2Scale(&gotvec,NULL,scale);
401 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
402 funcpointer = D3DXVec2Scale(NULL,NULL,scale);
403 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
405 /*_______________D3DXVec2Subtract__________________________*/
406 expectedvec.x = 10.0f; expectedvec.y = -5.0f;
407 D3DXVec2Subtract(&gotvec,&u,&v);
408 expect_vec(expectedvec,gotvec);
409 /* Tests the case NULL */
410 funcpointer = D3DXVec2Subtract(&gotvec,NULL,&v);
411 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
412 funcpointer = D3DXVec2Subtract(NULL,NULL,NULL);
413 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
417 static void D3X8Vector3Test(void)
419 D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w, x;
420 LPD3DXVECTOR3 funcpointer;
421 FLOAT coeff1, coeff2, expected, got, scale;
423 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
424 u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
425 v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
426 w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
427 x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
429 coeff1 = 2.0f; coeff2 = 5.0f;
432 /*_______________D3DXVec3Add__________________________*/
433 expectedvec.x = 11.0f; expectedvec.y = 3.0f; expectedvec.z = -2.0f;
434 D3DXVec3Add(&gotvec,&u,&v);
435 expect_vec3(expectedvec,gotvec);
436 /* Tests the case NULL */
437 funcpointer = D3DXVec3Add(&gotvec,NULL,&v);
438 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
439 funcpointer = D3DXVec3Add(NULL,NULL,NULL);
440 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
442 /*_______________D3DXVec3BaryCentric___________________*/
443 expectedvec.x = -35.0f; expectedvec.y = -67.0; expectedvec.z = 15.0f;
444 D3DXVec3BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
446 expect_vec3(expectedvec,gotvec);
448 /*_______________D3DXVec3CatmullRom____________________*/
449 expectedvec.x = 1458.0f; expectedvec.y = 22.1875f; expectedvec.z = 4141.375f;
450 D3DXVec3CatmullRom(&gotvec,&u,&v,&w,&x,scale);
451 expect_vec3(expectedvec,gotvec);
453 /*_______________D3DXVec3Cross________________________*/
454 expectedvec.x = -18.0f; expectedvec.y = 40.0f; expectedvec.z = -30.0f;
455 D3DXVec3Cross(&gotvec,&u,&v);
456 /* Tests the case NULL */
457 funcpointer = D3DXVec3Cross(&gotvec,NULL,&v);
458 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
459 funcpointer = D3DXVec3Cross(NULL,NULL,NULL);
460 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
462 /*_______________D3DXVec3Dot__________________________*/
464 got = D3DXVec3Dot(&u,&v);
465 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
466 /* Tests the case NULL */
468 got = D3DXVec3Dot(NULL,&v);
469 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
471 got = D3DXVec3Dot(NULL,NULL);
472 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
474 /*_______________D3DXVec3Hermite__________________________*/
475 expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
476 D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
477 expect_vec3(expectedvec,gotvec);
479 /*_______________D3DXVec3Length__________________________*/
481 got = D3DXVec3Length(&u);
482 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
483 /* Tests the case NULL */
485 got = D3DXVec3Length(NULL);
486 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
488 /*_______________D3DXVec3LengthSq________________________*/
490 got = D3DXVec3LengthSq(&u);
491 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
492 /* Tests the case NULL */
494 got = D3DXVec3LengthSq(NULL);
495 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
497 /*_______________D3DXVec3Lerp__________________________*/
498 expectedvec.x = 54.5f; expectedvec.y = 64.5f, expectedvec.z = 41.0f ;
499 D3DXVec3Lerp(&gotvec,&u,&v,scale);
500 expect_vec3(expectedvec,gotvec);
501 /* Tests the case NULL */
502 funcpointer = D3DXVec3Lerp(&gotvec,NULL,&v,scale);
503 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
504 funcpointer = D3DXVec3Lerp(NULL,NULL,NULL,scale);
505 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
507 /*_______________D3DXVec3Maximize__________________________*/
508 expectedvec.x = 9.0f; expectedvec.y = 6.0f; expectedvec.z = 2.0f;
509 D3DXVec3Maximize(&gotvec,&u,&v);
510 expect_vec3(expectedvec,gotvec);
511 /* Tests the case NULL */
512 funcpointer = D3DXVec3Maximize(&gotvec,NULL,&v);
513 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
514 funcpointer = D3DXVec3Maximize(NULL,NULL,NULL);
515 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
517 /*_______________D3DXVec3Minimize__________________________*/
518 expectedvec.x = 2.0f; expectedvec.y = -3.0f; expectedvec.z = -4.0f;
519 D3DXVec3Minimize(&gotvec,&u,&v);
520 expect_vec3(expectedvec,gotvec);
521 /* Tests the case NULL */
522 funcpointer = D3DXVec3Minimize(&gotvec,NULL,&v);
523 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
524 funcpointer = D3DXVec3Minimize(NULL,NULL,NULL);
525 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
527 /*_______________D3DXVec3Normalize_________________________*/
528 expectedvec.x = 9.0f/11.0f; expectedvec.y = 6.0f/11.0f; expectedvec.z = 2.0f/11.0f;
529 D3DXVec3Normalize(&gotvec,&u);
530 expect_vec3(expectedvec,gotvec);
531 /* Test the nul vector */
532 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
533 D3DXVec3Normalize(&gotvec,&nul);
534 expect_vec3(expectedvec,gotvec);
536 /*_______________D3DXVec3Scale____________________________*/
537 expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
538 D3DXVec3Scale(&gotvec,&u,scale);
539 expect_vec3(expectedvec,gotvec);
540 /* Tests the case NULL */
541 funcpointer = D3DXVec3Scale(&gotvec,NULL,scale);
542 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
543 funcpointer = D3DXVec3Scale(NULL,NULL,scale);
544 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
546 /*_______________D3DXVec3Subtract_______________________*/
547 expectedvec.x = 7.0f; expectedvec.y = 9.0f; expectedvec.z = 6.0f;
548 D3DXVec3Subtract(&gotvec,&u,&v);
549 expect_vec3(expectedvec,gotvec);
550 /* Tests the case NULL */
551 funcpointer = D3DXVec3Subtract(&gotvec,NULL,&v);
552 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
553 funcpointer = D3DXVec3Subtract(NULL,NULL,NULL);
554 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
558 static void D3X8Vector4Test(void)
560 D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
561 LPD3DXVECTOR4 funcpointer;
562 FLOAT coeff1, coeff2, expected, got, scale;
564 nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f;
565 u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
566 v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
567 w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
568 x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
569 coeff1 = 2.0f; coeff2 = 5.0;
572 /*_______________D3DXVec4Add__________________________*/
573 expectedvec.x = -2.0f; expectedvec.y = 6.0f; expectedvec.z = -1.0f; expectedvec.w = 17.0f;
574 D3DXVec4Add(&gotvec,&u,&v);
575 expect_vec4(expectedvec,gotvec);
576 /* Tests the case NULL */
577 funcpointer = D3DXVec4Add(&gotvec,NULL,&v);
578 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
579 funcpointer = D3DXVec4Add(NULL,NULL,NULL);
580 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
582 /*_______________D3DXVec4BaryCentric____________________*/
583 expectedvec.x = 8.0f; expectedvec.y = 26.0; expectedvec.z = -44.0f; expectedvec.w = -41.0f;
584 D3DXVec4BaryCentric(&gotvec,&u,&v,&w,coeff1,coeff2);
585 expect_vec4(expectedvec,gotvec);
587 /*_______________D3DXVec4CatmullRom____________________*/
588 expectedvec.x = 2754.625f; expectedvec.y = 2367.5625f; expectedvec.z = 1060.1875f; expectedvec.w = 131.3125f;
589 D3DXVec4CatmullRom(&gotvec,&u,&v,&w,&x,scale);
590 expect_vec4(expectedvec,gotvec);
592 /*_______________D3DXVec4Dot__________________________*/
594 got = D3DXVec4Dot(&u,&v);
595 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
596 /* Tests the case NULL */
598 got = D3DXVec4Dot(NULL,&v);
599 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
601 got = D3DXVec4Dot(NULL,NULL);
602 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
604 /*_______________D3DXVec4Hermite_________________________*/
605 expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
606 D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
607 expect_vec4(expectedvec,gotvec);
609 /*_______________D3DXVec4Length__________________________*/
611 got = D3DXVec4Length(&u);
612 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
613 /* Tests the case NULL */
615 got = D3DXVec4Length(NULL);
616 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
618 /*_______________D3DXVec4LengthSq________________________*/
620 got = D3DXVec4LengthSq(&u);
621 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
622 /* Tests the case NULL */
624 got = D3DXVec4LengthSq(NULL);
625 ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
627 /*_______________D3DXVec4Lerp__________________________*/
628 expectedvec.x = 27.0f; expectedvec.y = -11.0f; expectedvec.z = 62.5; expectedvec.w = 29.5;
629 D3DXVec4Lerp(&gotvec,&u,&v,scale);
630 expect_vec4(expectedvec,gotvec);
631 /* Tests the case NULL */
632 funcpointer = D3DXVec4Lerp(&gotvec,NULL,&v,scale);
633 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
634 funcpointer = D3DXVec4Lerp(NULL,NULL,NULL,scale);
635 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
637 /*_______________D3DXVec4Maximize__________________________*/
638 expectedvec.x = 1.0f; expectedvec.y = 4.0f; expectedvec.z = 4.0f; expectedvec.w = 10.0;
639 D3DXVec4Maximize(&gotvec,&u,&v);
640 expect_vec4(expectedvec,gotvec);
641 /* Tests the case NULL */
642 funcpointer = D3DXVec4Maximize(&gotvec,NULL,&v);
643 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
644 funcpointer = D3DXVec4Maximize(NULL,NULL,NULL);
645 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
647 /*_______________D3DXVec4Minimize__________________________*/
648 expectedvec.x = -3.0f; expectedvec.y = 2.0f; expectedvec.z = -5.0f; expectedvec.w = 7.0;
649 D3DXVec4Minimize(&gotvec,&u,&v);
650 expect_vec4(expectedvec,gotvec);
651 /* Tests the case NULL */
652 funcpointer = D3DXVec4Minimize(&gotvec,NULL,&v);
653 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
654 funcpointer = D3DXVec4Minimize(NULL,NULL,NULL);
655 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
657 /*_______________D3DXVec4Normalize_________________________*/
658 expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; expectedvec.w = 10.0f/11.0f;
659 D3DXVec4Normalize(&gotvec,&u);
660 expect_vec4(expectedvec,gotvec);
661 /* Test the nul vector */
662 expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; expectedvec.w = 0.0f;
663 D3DXVec4Normalize(&gotvec,&nul);
664 expect_vec4(expectedvec,gotvec);
666 /*_______________D3DXVec4Scale____________________________*/
667 expectedvec.x = -6.5f; expectedvec.y = -13.0f; expectedvec.z = -26.0f; expectedvec.w = -65.0f;
668 D3DXVec4Scale(&gotvec,&u,scale);
669 expect_vec4(expectedvec,gotvec);
670 /* Tests the case NULL */
671 funcpointer = D3DXVec4Scale(&gotvec,NULL,scale);
672 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
673 funcpointer = D3DXVec4Scale(NULL,NULL,scale);
674 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
676 /*_______________D3DXVec4Subtract__________________________*/
677 expectedvec.x = 4.0f; expectedvec.y = -2.0f; expectedvec.z = 9.0f; expectedvec.w = 3.0f;
678 D3DXVec4Subtract(&gotvec,&u,&v);
679 expect_vec4(expectedvec,gotvec);
680 /* Tests the case NULL */
681 funcpointer = D3DXVec4Subtract(&gotvec,NULL,&v);
682 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
683 funcpointer = D3DXVec4Subtract(NULL,NULL,NULL);
684 ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
692 D3X8QuaternionTest();