[glib: 2/4] tests: Test g_atomic_pointer_compare_and_exchange() returning false



commit 5dbaa18d6117a301e7b08da69af2c90ab9024657
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Oct 8 12:07:58 2019 +0100

    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>

 glib/tests/atomic.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c
index 22cb0ee77..b806c0fa5 100644
--- a/glib/tests/atomic.c
+++ b/glib/tests/atomic.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]