[libdazzle] tests: add negative cascade test



commit 94461f127cb799953ac6044b2869a4ada4610957
Author: Christian Hergert <chergert redhat com>
Date:   Mon Dec 18 15:14:56 2017 -0800

    tests: add negative cascade test
    
    This ensures that root doesn't trigger the dependents.

 tests/test-cancellable.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-cancellable.c b/tests/test-cancellable.c
index 879f00c..9809fa8 100644
--- a/tests/test-cancellable.c
+++ b/tests/test-cancellable.c
@@ -26,6 +26,36 @@ test_basic (void)
 }
 
 static void
+test_root (void)
+{
+  g_autoptr(GCancellable) root = g_cancellable_new ();
+  g_autoptr(GCancellable) a = g_cancellable_new ();
+  g_autoptr(GCancellable) b = g_cancellable_new ();
+  g_autoptr(GCancellable) a1 = g_cancellable_new ();
+  g_autoptr(GCancellable) a2 = g_cancellable_new ();
+
+  dzl_cancellable_chain (root, a);
+  dzl_cancellable_chain (root, b);
+  dzl_cancellable_chain (a, a1);
+  dzl_cancellable_chain (a, a2);
+
+  g_cancellable_cancel (root);
+
+  g_assert_cmpint (TRUE, ==, g_cancellable_is_cancelled (root));
+
+  g_assert_cmpint (FALSE, ==, g_cancellable_is_cancelled (a));
+  g_assert_cmpint (FALSE, ==, g_cancellable_is_cancelled (a1));
+  g_assert_cmpint (FALSE, ==, g_cancellable_is_cancelled (a2));
+  g_assert_cmpint (FALSE, ==, g_cancellable_is_cancelled (b));
+
+  g_clear_object (&root);
+  g_clear_object (&a);
+  g_clear_object (&b);
+  g_clear_object (&a1);
+  g_clear_object (&a2);
+}
+
+static void
 test_weak (void)
 {
   g_autoptr(GCancellable) root = g_cancellable_new ();
@@ -52,6 +82,7 @@ main (gint   argc,
 {
   g_test_init (&argc, &argv, NULL);
   g_test_add_func ("/Dazzle/Cancellable/basic", test_basic);
+  g_test_add_func ("/Dazzle/Cancellable/root", test_root);
   g_test_add_func ("/Dazzle/Cancellable/weak", test_weak);
   return g_test_run ();
 }


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