quartz: add tests for AmpFactorToDB and DBToAmpFactor
Robert Reif
reif at earthlink.net
Tue Jan 2 08:37:44 CST 2007
-------------- next part --------------
diff -puN wine.cvs/dlls/quartz/tests/db.c wine/dlls/quartz/tests/db.c
--- wine.cvs/dlls/quartz/tests/db.c 1969-12-31 19:00:00.000000000 -0500
+++ wine/dlls/quartz/tests/db.c 2007-01-02 09:18:19.000000000 -0500
@@ -0,0 +1,81 @@
+/*
+ * Unit tests for Direct Show dB conversion functions
+ *
+ * Copyright (C) 2007 Robert Reif
+ *
+ * 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, USA
+ */
+
+#include <stdio.h>
+
+#include "wine/test.h"
+#include "dshow.h"
+
+static LONG (WINAPI *pAmpFactorToDB)(LONG) = NULL;
+static LONG (WINAPI *pDBToAmpFactor)(LONG) = NULL;
+
+static void testDB(void)
+{
+ int i;
+ LONG amp, db;
+ struct a { int amp; int db; } amp_to_db[] = {
+ { 0, -9640 }, { 1, -9630 }, { 10, -7630 }, { 100, -5630 },
+ { 1000,-3630 }, { 10000, -1630 }, { 32767,-600 }, { 32768, -600 },
+ { 64535, -10 }, { 65435, 0 }, { 65525, 0 }, { 65534, 0 }, { 65535, 0 },
+ { -1, 0 }, { 65536, 0 }, { 100000, 0 }
+ };
+ struct b { int db; int amp; } db_to_amp[] = {
+ { 11, 65535 }, { 1, 65535 }, { 0, 65535 }, { -1, 65535 },
+ { -600, 32845 }, { -9640, 0 }, { -10000, 0 }, { -10001, 0 },
+ { -10011, 0 }
+ };
+
+ for (i = 0; i < sizeof(amp_to_db) / sizeof(amp_to_db[0]); i++)
+ {
+ amp = amp_to_db[i].amp;
+ db = pAmpFactorToDB(amp);
+ ok(db == amp_to_db[i].db,
+ "AmpFactorToDB(%d) returned %d, should be %d\n",
+ amp, db, amp_to_db[i].db);
+ }
+
+ for (i = 0; i < sizeof(db_to_amp) / sizeof(db_to_amp[0]); i++)
+ {
+ db = db_to_amp[i].db;
+ amp = pDBToAmpFactor(db);
+ ok(amp == db_to_amp[i].amp,
+ "DBToAmpFactor(%d) returned %d, should be %d\n",
+ db, amp, db_to_amp[i].amp);
+ }
+}
+
+START_TEST(db)
+{
+ HMODULE hQuartz;
+
+ hQuartz = LoadLibraryA("quartz.dll");
+
+ if (!hQuartz)
+ {
+ trace("quartz.dll not found\n");
+ return;
+ }
+
+ pAmpFactorToDB = (void*)GetProcAddress(hQuartz,"AmpFactorToDB");
+ pDBToAmpFactor = (void*)GetProcAddress(hQuartz,"DBToAmpFactor");
+
+ if (pAmpFactorToDB && pDBToAmpFactor)
+ testDB();
+}
diff -puN wine.cvs/dlls/quartz/tests/Makefile.in wine/dlls/quartz/tests/Makefile.in
--- wine.cvs/dlls/quartz/tests/Makefile.in 2006-12-30 03:10:54.000000000 -0500
+++ wine/dlls/quartz/tests/Makefile.in 2007-01-02 09:10:54.000000000 -0500
@@ -7,6 +7,7 @@ IMPORTS = ole32 user32 gdi32 kernel32
EXTRALIBS = -lstrmiids
CTESTS = \
+ db.c \
filtergraph.c \
memallocator.c
More information about the wine-patches
mailing list