From 047d88caa00db9e9b31c88682703462d0d6fa201 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 21 Oct 2016 15:25:52 +0100 Subject: [PATCH] Eo: Add test for refcount in efl_add_ref This commits adds a regression test to the previous commit. --- src/tests/eo/suite/eo_test_general.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c index e142d67..bb34b7d 100644 --- a/src/tests/eo/suite/eo_test_general.c +++ b/src/tests/eo/suite/eo_test_general.c @@ -618,6 +618,33 @@ START_TEST(efl_refs) efl_del(obj2); efl_del(obj3); + /* Setting and removing parents for add_ref */ + obj = efl_add(SIMPLE_CLASS, NULL); + obj2 = efl_add_ref(SIMPLE_CLASS, obj); + obj3 = efl_add_ref(SIMPLE_CLASS, NULL); + + ck_assert_int_eq(efl_ref_get(obj2), 2); + ck_assert_int_eq(efl_ref_get(obj3), 1); + + efl_parent_set(obj2, obj3); + efl_parent_set(obj3, obj); + ck_assert_int_eq(efl_ref_get(obj2), 2); + ck_assert_int_eq(efl_ref_get(obj3), 2); + + efl_parent_set(obj2, NULL); + efl_parent_set(obj3, NULL); + ck_assert_int_eq(efl_ref_get(obj2), 1); + ck_assert_int_eq(efl_ref_get(obj3), 1); + + efl_parent_set(obj2, obj); + efl_parent_set(obj3, obj); + ck_assert_int_eq(efl_ref_get(obj2), 2); + ck_assert_int_eq(efl_ref_get(obj3), 2); + + efl_del(obj); + efl_del(obj2); + efl_del(obj3); + /* Just check it doesn't seg atm. */ obj = efl_add(SIMPLE_CLASS, NULL); efl_ref(obj); -- 2.7.4