mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-07 17:54:05 +02:00
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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user