Jacek Caban : winmm/tests: Introduce compare_uint helper.
Alexandre Julliard
julliard at winehq.org
Wed Jun 3 16:40:58 CDT 2020
Module: wine
Branch: master
Commit: 72a36736a95787376675656a8d940ab3ce984a3a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=72a36736a95787376675656a8d940ab3ce984a3a
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 27 23:55:44 2020 +0200
winmm/tests: Introduce compare_uint helper.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winmm/tests/mixer.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/winmm/tests/mixer.c b/dlls/winmm/tests/mixer.c
index f03a71e1f3..b9e35aa519 100644
--- a/dlls/winmm/tests/mixer.c
+++ b/dlls/winmm/tests/mixer.c
@@ -36,6 +36,12 @@
#include "winmm_test.h"
+static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
+{
+ unsigned int diff = x > y ? x - y : y - x;
+ return diff <= max_diff;
+}
+
static const char * line_flags(DWORD fdwLine)
{
static char flags[100];
@@ -253,11 +259,11 @@ static void mixer_test_controlA(HMIXEROBJ mix, MIXERCONTROLA *control)
mmsys_error(rc));
if (rc==MMSYSERR_NOERROR) {
/* result may not match exactly because of rounding */
- ok(abs(ret_value.dwValue-new_value.dwValue)<=1,
+ ok(compare_uint(ret_value.dwValue, new_value.dwValue, 1),
"Couldn't change value from %d to %d, returned %d\n",
value.dwValue,new_value.dwValue,ret_value.dwValue);
- if (abs(ret_value.dwValue-new_value.dwValue)<=1) {
+ if (compare_uint(ret_value.dwValue, new_value.dwValue, 1)) {
details.cbStruct = sizeof(MIXERCONTROLDETAILS);
details.dwControlID = control->dwControlID;
details.cChannels = 1;
@@ -632,11 +638,11 @@ static void mixer_test_controlW(HMIXEROBJ mix, MIXERCONTROLW *control)
mmsys_error(rc));
if (rc==MMSYSERR_NOERROR) {
/* result may not match exactly because of rounding */
- ok(abs(ret_value.dwValue-new_value.dwValue)<=1,
+ ok(compare_uint(ret_value.dwValue, new_value.dwValue, 1),
"Couldn't change value from %d to %d, returned %d\n",
value.dwValue,new_value.dwValue,ret_value.dwValue);
- if (abs(ret_value.dwValue-new_value.dwValue)<=1) {
+ if (compare_uint(ret_value.dwValue, new_value.dwValue, 1)) {
details.cbStruct = sizeof(MIXERCONTROLDETAILS);
details.dwControlID = control->dwControlID;
details.cChannels = 1;
More information about the wine-cvs
mailing list