summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite/eo_test_general.c
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-08-26 10:02:01 +0100
committerTom Hacohen <tom@stosb.com>2015-08-26 10:11:18 +0100
commit9c78ee0bf4125c095e85f7fcf9921586cda64a52 (patch)
tree0172745b12d86536b3a829cecd96a55d1e43ec34 /src/tests/eo/suite/eo_test_general.c
parentb9c24fa951c852d267702e318c78b7dcbdd3c3e0 (diff)
Eo base: Change parent_set to be an assignment of ref.
After this change, parent_set assigns a ref, so for example: obj = eo_add(CLASS, parent); /* Ref is 1 */ eo_do(obj, eo_parent_set(parent2)); /* Ref is 1 */ eo_ref(obj); /* Ref is 2 */ eo_do(obj, eo_parent_set(NULL)); /* Ref is 1, giving the ref to NULL */ eo_do(obj, eo_parent_set(parent)); /* Ref is 1 */ This is following a discussion on the ML about commit 8689d54471aafdd7a5b5a27ce116bf2ab68c1042. @feature
Diffstat (limited to '')
-rw-r--r--src/tests/eo/suite/eo_test_general.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 47064cf373..9121f8fac0 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -464,6 +464,29 @@ START_TEST(eo_refs)
464 ck_assert_int_eq(eo_ref_get(obj2), 1); 464 ck_assert_int_eq(eo_ref_get(obj2), 1);
465 ck_assert_int_eq(eo_ref_get(obj3), 2); 465 ck_assert_int_eq(eo_ref_get(obj3), 2);
466 466
467 /* Setting and removing parents. */
468 obj = eo_add(SIMPLE_CLASS, NULL);
469 obj2 = eo_ref(eo_add(SIMPLE_CLASS, obj));
470 obj3 = eo_ref(eo_add(SIMPLE_CLASS, NULL));
471
472 eo_do(obj2, eo_parent_set(obj3));
473 eo_do(obj3, eo_parent_set(obj));
474 ck_assert_int_eq(eo_ref_get(obj2), 2);
475 ck_assert_int_eq(eo_ref_get(obj3), 2);
476
477 eo_do(obj2, eo_parent_set(NULL));
478 eo_do(obj3, eo_parent_set(NULL));
479 ck_assert_int_eq(eo_ref_get(obj2), 1);
480 ck_assert_int_eq(eo_ref_get(obj3), 1);
481
482 eo_do(obj2, eo_parent_set(obj));
483 eo_do(obj3, eo_parent_set(obj));
484 ck_assert_int_eq(eo_ref_get(obj2), 1);
485 ck_assert_int_eq(eo_ref_get(obj3), 1);
486
487 eo_del(obj);
488 eo_del(obj2);
489 eo_del(obj3);
467 490
468 /* Just check it doesn't seg atm. */ 491 /* Just check it doesn't seg atm. */
469 obj = eo_add(SIMPLE_CLASS, NULL); 492 obj = eo_add(SIMPLE_CLASS, NULL);