jackdanielz pushed a commit to branch master.
commit d29fc36e1b2835a8be155919587f809016f05b69
Author: Daniel Zaoui <[email protected]>
Date: Thu Apr 18 13:55:55 2013 +0300
Eo: tests to check eo ptrs indirection feature.
The test doesn't fail if the feature is disabled.
---
src/tests/eo/suite/eo_test_class_errors.c | 4 ++
src/tests/eo/suite/eo_test_general.c | 75 +++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/src/tests/eo/suite/eo_test_class_errors.c
b/src/tests/eo/suite/eo_test_class_errors.c
index 658ff6d..302b107 100644
--- a/src/tests/eo/suite/eo_test_class_errors.c
+++ b/src/tests/eo/suite/eo_test_class_errors.c
@@ -437,7 +437,11 @@ START_TEST(eo_op_types)
fail_if(!klass);
TEST_EO_ERROR("eo_class_name_get", NULL);
+#ifdef HAVE_EO_ID
+ ctx.expected_level = EINA_LOG_LEVEL_ERR;
+#else
ctx.expected_level = EINA_LOG_LEVEL_CRITICAL;
+#endif
/* Add class checks here... */
Eo *obj = eo_add(klass, NULL);
eo_do(obj, simple_a_set(7), simple_a_print(), simple_class_hi_print());
diff --git a/src/tests/eo/suite/eo_test_general.c
b/src/tests/eo/suite/eo_test_general.c
index f3d0888..866feb1 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -822,6 +822,80 @@ START_TEST(eo_add_do_and_custom)
}
END_TEST
+START_TEST(eo_pointers_indirection)
+{
+#ifdef HAVE_EO_ID
+ eo_init();
+
+ static const Eo_Class_Description class_desc = {
+ EO_VERSION,
+ "Simple",
+ EO_CLASS_TYPE_REGULAR,
+ EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
+ NULL,
+ 0,
+ NULL,
+ NULL
+ };
+
+ const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
+ fail_if(!klass);
+
+ /* Check simple id validity */
+ Eo *obj = eo_add(klass, NULL);
+ fail_if(!obj);
+ fail_if(!eo_isa(obj, klass));
+ obj = (Eo *)((char *)(obj) + 1);
+ fail_if(eo_isa(obj, klass));
+ obj = (Eo *)((char *)(obj) - 1);
+ fail_if(!eo_isa(obj, klass));
+ eo_unref(obj);
+ fail_if(eo_isa(obj, klass));
+
+ /* Check id invalidity after deletion */
+ Eo *obj1 = eo_add(klass, NULL);
+ fail_if(!obj1);
+ eo_unref(obj1);
+ Eo *obj2 = eo_add(klass, NULL);
+ fail_if(!obj2);
+ fail_if(!eo_isa(obj2, klass));
+ fail_if(eo_isa(obj1, klass));
+ eo_unref(obj2);
+
+#define NB_OBJS 100
+ unsigned int obj_id;
+ Eo **objs = calloc(NB_OBJS, sizeof(Eo *));
+ fail_if(!objs);
+ /* Creation of the objects */
+ for ( obj_id = 0; obj_id < NB_OBJS; obj_id++)
+ {
+ objs[obj_id] = eo_add(klass, NULL);
+ fail_if(!objs[obj_id]);
+ fail_if(!eo_isa(objs[obj_id], klass));
+ }
+ /* Deletion of half of the objects */
+ for ( obj_id = 0; obj_id < NB_OBJS; obj_id+=2)
+ {
+ eo_unref(objs[obj_id]);
+ fail_if(eo_isa(objs[obj_id], klass));
+ }
+ /* Creation of half of the objects */
+ for ( obj_id = 0; obj_id < NB_OBJS; obj_id+=2)
+ {
+ objs[obj_id] = eo_add(klass, NULL);
+ fail_if(!objs[obj_id]);
+ fail_if(!eo_isa(objs[obj_id], klass));
+ }
+ /* Deletion of all the objects */
+ for ( obj_id = 0; obj_id < NB_OBJS; obj_id++)
+ eo_unref(objs[obj_id]);
+ free(objs);
+
+ eo_shutdown();
+#endif
+}
+END_TEST
+
void eo_test_general(TCase *tc)
{
tcase_add_test(tc, eo_generic_data);
@@ -837,4 +911,5 @@ void eo_test_general(TCase *tc)
tcase_add_test(tc, eo_multiple_do);
tcase_add_test(tc, eo_add_do_and_custom);
tcase_add_test(tc, eo_signals);
+ tcase_add_test(tc, eo_pointers_indirection);
}
--
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr