[PATCH] Implement D3DX8Vec2Length with a test

Adam David (none) david at localhost.
Sat Oct 13 17:39:54 CDT 2007


---
 Makefile.in                  |    1 +
 configure                    |    3 ++
 configure.ac                 |    1 +
 dlls/d3dx8/tests/Makefile.in |   13 +++++++++++
 dlls/d3dx8/tests/math.c      |   48 +++++++++++++++++++++++++++++++++++++++=
+++
 include/Makefile.in          |    1 +
 include/d3dx8math.h          |    2 +
 include/d3dx8math.inl        |   28 ++++++++++++++++++++++++
 8 files changed, 97 insertions(+), 0 deletions(-)
 create mode 100644 dlls/d3dx8/tests/Makefile.in
 create mode 100644 dlls/d3dx8/tests/math.c
 create mode 100644 include/d3dx8math.inl

diff --git a/Makefile.in b/Makefile.in
index 3ff8abb..71ec156 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -198,6 +198,7 @@ ALL_MAKEFILES =3D \
 =09dlls/d3drm/Makefile \
 =09dlls/d3drm/tests/Makefile \
 =09dlls/d3dx8/Makefile \
+=09dlls/d3dx8/tests/Makefile \
 =09dlls/d3dxof/Makefile \
 =09dlls/dbghelp/Makefile \
 =09dlls/dciman32/Makefile \
diff --git a/configure b/configure
index 9e1e78b..354c02a 100755
--- a/configure
+++ b/configure
@@ -20352,6 +20352,8 @@ ac_config_files=3D"$ac_config_files dlls/d3drm/tests=
/Makefile"
=20
 ac_config_files=3D"$ac_config_files dlls/d3dx8/Makefile"
=20
+ac_config_files=3D"$ac_config_files dlls/d3dx8/tests/Makefile"
+
 ac_config_files=3D"$ac_config_files dlls/d3dxof/Makefile"
=20
 ac_config_files=3D"$ac_config_files dlls/dbghelp/Makefile"
@@ -21590,6 +21592,7 @@ do
     "dlls/d3drm/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/d3drm/Makefil=
e" ;;
     "dlls/d3drm/tests/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/d3drm/t=
ests/Makefile" ;;
     "dlls/d3dx8/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/d3dx8/Makefil=
e" ;;
+    "dlls/d3dx8/tests/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/d3dx8/t=
ests/Makefile" ;;
     "dlls/d3dxof/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/d3dxof/Makef=
ile" ;;
     "dlls/dbghelp/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/dbghelp/Mak=
efile" ;;
     "dlls/dciman32/Makefile") CONFIG_FILES=3D"$CONFIG_FILES dlls/dciman32/M=
akefile" ;;
diff --git a/configure.ac b/configure.ac
index 6bb3faa..50e4f3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1596,6 +1596,7 @@ AC_CONFIG_FILES([dlls/d3dim/Makefile])
 AC_CONFIG_FILES([dlls/d3drm/Makefile])
 AC_CONFIG_FILES([dlls/d3drm/tests/Makefile])
 AC_CONFIG_FILES([dlls/d3dx8/Makefile])
+AC_CONFIG_FILES([dlls/d3dx8/tests/Makefile])
 AC_CONFIG_FILES([dlls/d3dxof/Makefile])
 AC_CONFIG_FILES([dlls/dbghelp/Makefile])
 AC_CONFIG_FILES([dlls/dciman32/Makefile])
diff --git a/dlls/d3dx8/tests/Makefile.in b/dlls/d3dx8/tests/Makefile.in
new file mode 100644
index 0000000..1cf5740
--- /dev/null
+++ b/dlls/d3dx8/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR =3D @top_srcdir@
+TOPOBJDIR =3D ../../..
+SRCDIR    =3D @srcdir@
+VPATH     =3D @srcdir@
+TESTDLL   =3D d3dx8.dll
+IMPORTS   =3D kernel32
+EXTRALIBS =3D -ldxguid
+
+CTESTS =3D math.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
new file mode 100644
index 0000000..8d22ef4
--- /dev/null
+++ b/dlls/d3dx8/tests/math.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007 David Adam
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, US=
A
+ */
+
+#include <assert.h>
+#include "d3dx8math.h"
+#include "d3dx8math.inl"
+
+#include "wine/test.h"
+
+#define admitted_error 0.00001f
+
+static void D3X8Vector2Test(void)
+{
+    D3DXVECTOR2 u;
+    FLOAT expected, got;
+
+    u.x=3D3.0f; u.y=3D4.0f;
+
+/*_______________D3DXVec2Length__________________________*/
+   expected =3D 5.0f;
+   got =3D D3DXVec2Length(&u);
+   ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", e=
xpected, got);
+   /* Tests the case NULL */
+    expected=3D0.0f;
+    got=3D D3DXVec2Length(NULL);
+    ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
+}
+START_TEST(math)
+{
+    D3X8Vector2Test();
+}
+
+
diff --git a/include/Makefile.in b/include/Makefile.in
index de8b86a..222058a 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -107,6 +107,7 @@ SRCDIR_INCLUDES =3D \
 =09d3dx8.h \
 =09d3dx8core.h \
 =09d3dx8math.h \
+=09d3dx8math.inl \
 =09dbghelp.h \
 =09dbinit.idl \
 =09dbprop.idl \
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 71de014..aa561ed 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -58,4 +58,6 @@ typedef struct D3DXCOLOR
     FLOAT r, g, b, a;
 } D3DXCOLOR, *LPD3DXCOLOR;
=20
+FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv);
+
 #endif /* __D3DX8MATH_H__ */
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
new file mode 100644
index 0000000..e9b1b6d
--- /dev/null
+++ b/include/d3dx8math.inl
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2007 David Adam
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, US=
A
+ */
+
+#ifndef __D3DX8MATH_INL__
+#define __D3DX8MATH_INL__
+
+extern inline FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv)
+{
+    if (!pv) return 0.0f;
+    return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) );
+}
+
+#endif
--=20
1.5.3.2


--=_502huo0it2o8--



More information about the wine-patches mailing list