Commit 2ad5d4f1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

quartz/tests: Fix -Wabsolute-value warnings.

parent cca639fa
...@@ -41,6 +41,12 @@ typedef struct TestFilterImpl ...@@ -41,6 +41,12 @@ typedef struct TestFilterImpl
UINT nPins; UINT nPins;
} TestFilterImpl; } TestFilterImpl;
static BOOL compare_time(ULONGLONG x, ULONGLONG y, unsigned int max_diff)
{
ULONGLONG diff = x > y ? x - y : y - x;
return diff <= max_diff;
}
static WCHAR *create_file(const WCHAR *name, const char *data, DWORD size) static WCHAR *create_file(const WCHAR *name, const char *data, DWORD size)
{ {
static WCHAR pathW[MAX_PATH]; static WCHAR pathW[MAX_PATH];
...@@ -4057,13 +4063,13 @@ static void test_graph_seeking(void) ...@@ -4057,13 +4063,13 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time); hr = IMediaSeeking_GetCurrentPosition(seeking, &time);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */ if (winetest_interactive) /* Timing problems make this test too liable to fail. */
ok(abs(time - 1234 * 10000) < 40 * 10000, ok(compare_time(time, 1234 * 10000, 40 * 10000),
"Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(time)); "Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef; current = stop = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop); hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */ if (winetest_interactive) /* Timing problems make this test too liable to fail. */
ok(abs(current - 1234 * 10000) < 40 * 10000, ok(compare_time(current, 1234 * 10000, 40 * 10000),
"Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(current)); "Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(current));
ok(stop == 9000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop)); ok(stop == 9000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
...@@ -4080,13 +4086,13 @@ static void test_graph_seeking(void) ...@@ -4080,13 +4086,13 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time); hr = IMediaSeeking_GetCurrentPosition(seeking, &time);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */ if (winetest_interactive) /* Timing problems make this test too liable to fail. */
ok(abs(time - 1334 * 10000) < 80 * 10000, ok(compare_time(time, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time)); "Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef; current = stop = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop); hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */ if (winetest_interactive) /* Timing problems make this test too liable to fail. */
ok(abs(current - 1334 * 10000) < 80 * 10000, ok(compare_time(current, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current)); "Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current));
ok(stop == 8000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop)); ok(stop == 8000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
...@@ -4100,13 +4106,13 @@ static void test_graph_seeking(void) ...@@ -4100,13 +4106,13 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time); hr = IMediaSeeking_GetCurrentPosition(seeking, &time);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */ if (winetest_interactive) /* Timing problems make this test too liable to fail. */
ok(abs(time - 1334 * 10000) < 80 * 10000, ok(compare_time(time, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time)); "Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef; current = stop = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop); hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
if (winetest_interactive) /* Timing problems make this test too liable to fail. */ if (winetest_interactive) /* Timing problems make this test too liable to fail. */
ok(abs(current - 1334 * 10000) < 80 * 10000, ok(compare_time(current, 1334 * 10000, 80 * 10000),
"Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current)); "Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current));
ok(stop == 8000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop)); ok(stop == 8000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
......
...@@ -24,6 +24,12 @@ ...@@ -24,6 +24,12 @@
static ULONGLONG (WINAPI *pGetTickCount64)(void); static ULONGLONG (WINAPI *pGetTickCount64)(void);
static BOOL compare_time(REFERENCE_TIME x, REFERENCE_TIME y, unsigned int max_diff)
{
REFERENCE_TIME diff = x > y ? x - y : y - x;
return diff <= max_diff;
}
static IReferenceClock *create_system_clock(void) static IReferenceClock *create_system_clock(void)
{ {
IReferenceClock *clock = NULL; IReferenceClock *clock = NULL;
...@@ -181,7 +187,7 @@ static void test_get_time(void) ...@@ -181,7 +187,7 @@ static void test_get_time(void)
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time1 % 10000 == 0, "Expected no less than 1ms coarseness, but got time %s.\n", ok(time1 % 10000 == 0, "Expected no less than 1ms coarseness, but got time %s.\n",
wine_dbgstr_longlong(time1)); wine_dbgstr_longlong(time1));
ok(abs(time1 - time2) < 20 * 10000, "Expected about %s, got %s.\n", ok(compare_time(time1, time2, 20 * 10000), "Expected about %s, got %s.\n",
wine_dbgstr_longlong(time2), wine_dbgstr_longlong(time1)); wine_dbgstr_longlong(time2), wine_dbgstr_longlong(time1));
hr = IReferenceClock_GetTime(clock, &time2); hr = IReferenceClock_GetTime(clock, &time2);
......
...@@ -73,18 +73,19 @@ static inline BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TY ...@@ -73,18 +73,19 @@ static inline BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TY
static BOOL compare_double(double f, double g, unsigned int ulps) static BOOL compare_double(double f, double g, unsigned int ulps)
{ {
int64_t x = *(int64_t *)&f; uint64_t x = *(ULONGLONG *)&f;
int64_t y = *(int64_t *)&g; uint64_t y = *(ULONGLONG *)&g;
if (x < 0) if (f < 0)
x = INT64_MIN - x; x = ~x + 1;
if (y < 0) else
y = INT64_MIN - y; x |= ((ULONGLONG)1)<<63;
if (g < 0)
if (abs(x - y) > ulps) y = ~y + 1;
return FALSE; else
y |= ((ULONGLONG)1)<<63;
return TRUE; return (x>y ? x-y : y-x) <= ulps;
} }
static IFilterGraph2 *create_graph(void) static IFilterGraph2 *create_graph(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment