diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-09-30 10:59:47 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-10-18 09:15:54 +1000 |
commit | 82c60232c07f50774ccc0198950f64c9338057a5 (patch) | |
tree | 91f77e7fe8f80b6047c4bcb3f24fc529754f154c /test | |
parent | fb84be47db7cdaff406792c08e34670e8e0cbda9 (diff) |
dix: add valuator_mask_fetch_double()
Using this call simplifies callers that don't know if the mask bit is set.
Before:
if (valuator_mask_isset(mask, valnum))
value = valuator_mask_get_double(mask, valnum));
else
value = someothervalue;
Now:
if (!valuator_mask_fetch_double(mask, valnum, &value))
value = someothervalue;
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/input.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/input.c b/test/input.c index afc4d4d99..5fb9a90a2 100644 --- a/test/input.c +++ b/test/input.c @@ -1199,14 +1199,19 @@ static void dix_input_valuator_masks(void) assert(valuator_mask_num_valuators(mask) == num_vals); for (i = 0; i < nvaluators; i++) { + double val; if (i < first_val || i >= first_val + num_vals) + { assert(!valuator_mask_isset(mask, i)); - else + assert(!valuator_mask_fetch_double(mask, i, &val)); + } else { assert(valuator_mask_isset(mask, i)); assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]); assert(valuator_mask_get_double(mask, i) == val_ranged[i - first_val]); + assert(valuator_mask_fetch_double(mask, i, &val)); + assert(val_ranged[i - first_val] == val); } } @@ -1218,10 +1223,18 @@ static void dix_input_valuator_masks(void) for (i = 0; i < nvaluators; i++) { + double a, b; assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i)); + + if (!valuator_mask_isset(mask, i)) + continue; + assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i)); assert(valuator_mask_get_double(mask, i) == valuator_mask_get_double(copy, i)); + assert(valuator_mask_fetch_double(mask, i, &a)); + assert(valuator_mask_fetch_double(copy, i, &b)); + assert(a == b); } valuator_mask_free(&mask); |