quartz/tests: Use compare_double() to test IBasicVideo::get_AvgTimePerFrame().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-10-22 15:16:42 -05:00 committed by Alexandre Julliard
parent 09e32f57b7
commit f4b04e2e84
1 changed files with 19 additions and 1 deletions

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdint.h>
#define COBJMACROS
#include "dshow.h"
#include "d3d9.h"
@ -65,6 +66,23 @@ static inline BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TY
&& !memcmp(a->pbFormat, b->pbFormat, a->cbFormat);
}
static BOOL compare_double(double f, double g, unsigned int ulps)
{
uint64_t x = *(ULONGLONG *)&f;
uint64_t y = *(ULONGLONG *)&g;
if (f < 0)
x = ~x + 1;
else
x |= ((ULONGLONG)1)<<63;
if (g < 0)
y = ~y + 1;
else
y |= ((ULONGLONG)1)<<63;
return (x>y ? x-y : y-x) <= ulps;
}
static IFilterGraph2 *create_graph(void)
{
IFilterGraph2 *ret;
@ -2707,7 +2725,7 @@ static void test_basic_video(void)
reftime = 0.0;
hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(reftime == 0.02, "Got frame rate %.16e.\n", reftime);
ok(compare_double(reftime, 0.02, 1 << 28), "Got frame rate %.16e.\n", reftime);
l = 0xdeadbeef;
hr = IBasicVideo_get_BitRate(video, &l);