tests: Rearrange double/int comparisons in srvtarget to avoid casts

By keeping `expected` as a `double` for longer, we avoid having to cast
when populating the elements of `ordering`, to avoid
`-Wfloat-conversion` warnings.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
This commit is contained in:
Philip Withnall 2024-06-28 14:25:38 +01:00
parent 2713255574
commit ebe609eeef
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -30,7 +30,8 @@
struct {
const char *order;
int expected, seen;
gdouble expected;
unsigned int seen;
} ordering[] = {
/* There are 32 legitimate orderings; the result always has to start
* with either "fe" (usually) or "ef" (rarely). For the remaining
@ -141,8 +142,8 @@ test_srv_target_ordering (void)
*/
for (o = 0; o < NUM_ORDERINGS; o++)
{
g_assert_cmpint (ordering[o].seen, >, ordering[o].expected / 2);
g_assert_cmpint (ordering[o].seen, <, ordering[o].expected * 2);
g_assert_cmpuint (ordering[o].seen, >, (guint64) (ordering[o].expected / 2));
g_assert_cmpuint (ordering[o].seen, <, (guint64) (ordering[o].expected * 2));
}
g_resolver_free_targets (targets);