[PATCH 08/12] winmm/tests: Introduce compare_uint helper.
Andrew Eikum
aeikum at codeweavers.com
Wed Jun 3 07:44:41 CDT 2020
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Wed, May 27, 2020 at 11:55:44PM +0200, Jacek Caban wrote:
> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
> ---
> 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-devel
mailing list