mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-08 18:36:17 +01:00
tests: Factor out common calculations in test_basic_bits() test
This decreases the overall test time from 0.17s to 0.12s for me, and will help further in the following commit where I’m going to repeat some of these calculations again for further comparisons. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
17ffe7b303
commit
d5e6793b83
@ -310,27 +310,32 @@ test_basic_bits (void)
|
|||||||
/* we loop like this: 0, -1, 1, -2, 2, -3, 3, ... */
|
/* we loop like this: 0, -1, 1, -2, 2, -3, 3, ... */
|
||||||
for (i = 0; (glong) i < 1500; i = -(i + ((glong) i >= 0)))
|
for (i = 0; (glong) i < 1500; i = -(i + ((glong) i >= 0)))
|
||||||
{
|
{
|
||||||
|
guint naive_bit_storage_i = naive_bit_storage (i);
|
||||||
|
|
||||||
#if TEST_BUILTINS
|
#if TEST_BUILTINS
|
||||||
g_assert_cmpint (naive_bit_storage (i), ==, builtin_bit_storage (i));
|
g_assert_cmpint (naive_bit_storage_i, ==, builtin_bit_storage (i));
|
||||||
#endif
|
#endif
|
||||||
g_assert_cmpint (naive_bit_storage (i), ==, g_bit_storage (i));
|
g_assert_cmpint (naive_bit_storage_i, ==, g_bit_storage (i));
|
||||||
|
|
||||||
for (nth_bit = -3; nth_bit <= 2 + GLIB_SIZEOF_LONG * 8; nth_bit++)
|
for (nth_bit = -3; nth_bit <= 2 + GLIB_SIZEOF_LONG * 8; nth_bit++)
|
||||||
{
|
{
|
||||||
|
gint naive_bit_nth_lsf_i_nth_bit = naive_bit_nth_lsf (i, nth_bit);
|
||||||
|
gint naive_bit_nth_msf_i_nth_bit = naive_bit_nth_msf (i, nth_bit);
|
||||||
|
|
||||||
#if TEST_BUILTINS
|
#if TEST_BUILTINS
|
||||||
g_assert_cmpint (naive_bit_nth_lsf (i, nth_bit), ==,
|
g_assert_cmpint (naive_bit_nth_lsf_i_nth_bit, ==,
|
||||||
builtin_bit_nth_lsf1 (i, nth_bit));
|
builtin_bit_nth_lsf1 (i, nth_bit));
|
||||||
g_assert_cmpint (naive_bit_nth_lsf (i, nth_bit), ==,
|
g_assert_cmpint (naive_bit_nth_lsf_i_nth_bit, ==,
|
||||||
builtin_bit_nth_lsf2 (i, nth_bit));
|
builtin_bit_nth_lsf2 (i, nth_bit));
|
||||||
#endif
|
#endif
|
||||||
g_assert_cmpint (naive_bit_nth_lsf (i, nth_bit), ==,
|
g_assert_cmpint (naive_bit_nth_lsf_i_nth_bit, ==,
|
||||||
g_bit_nth_lsf (i, nth_bit));
|
g_bit_nth_lsf (i, nth_bit));
|
||||||
|
|
||||||
#if TEST_BUILTINS
|
#if TEST_BUILTINS
|
||||||
g_assert_cmpint (naive_bit_nth_msf (i, nth_bit), ==,
|
g_assert_cmpint (naive_bit_nth_msf_i_nth_bit, ==,
|
||||||
builtin_bit_nth_msf (i, nth_bit));
|
builtin_bit_nth_msf (i, nth_bit));
|
||||||
#endif
|
#endif
|
||||||
g_assert_cmpint (naive_bit_nth_msf (i, nth_bit), ==,
|
g_assert_cmpint (naive_bit_nth_msf_i_nth_bit, ==,
|
||||||
g_bit_nth_msf (i, nth_bit));
|
g_bit_nth_msf (i, nth_bit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user