tests: Test g_atomic_pointer_compare_and_exchange() returning false

There were tests for the situation where it does the exchange and
returns true, but no tests for the situation where it returns false.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-10-08 12:07:58 +01:00
parent 2eb3762241
commit 5dbaa18d61

View File

@ -80,6 +80,9 @@ test_types (void)
g_atomic_pointer_set (&vp, 0);
vp2 = g_atomic_pointer_get (&vp);
g_assert_true (vp2 == 0);
res = g_atomic_pointer_compare_and_exchange (&vp, &s, &s);
g_assert_false (res);
g_assert_true (vp == 0);
res = g_atomic_pointer_compare_and_exchange (&vp, 0, 0);
g_assert_true (res);
g_assert_true (vp == 0);
@ -185,6 +188,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_atomic_pointer_set (&vp, 0);
vp2 = g_atomic_pointer_get (&vp);
g_assert_true (vp2 == 0);
res = g_atomic_pointer_compare_and_exchange (&vp, &s, &s);
g_assert_false (res);
g_assert_true (vp == 0);
res = g_atomic_pointer_compare_and_exchange (&vp, 0, 0);
g_assert_true (res);
g_assert_true (vp == 0);