Eolian/Tests: add test for consts
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Wed, 21 May 2014 08:39:16 +0000 (11:39 +0300)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Mon, 26 May 2014 10:56:06 +0000 (13:56 +0300)
This tests checks the different 'const' possibilities in the .eo file
and their good parsing.

src/Makefile_Eolian.am
src/tests/eolian/data/consts.eo [new file with mode: 0644]
src/tests/eolian/eolian_parsing.c

index a945ea1ecde6c11eee7f8e634575665749066c9b..e4a189fe0f294ad1c5dc7ea5e3d2e1376d92348d 100644 (file)
@@ -93,5 +93,6 @@ tests/eolian/data/typedef.eo \
 tests/eolian/data/object_impl.eo \
 tests/eolian/data/object_impl_ref.c \
 tests/eolian/data/object_impl_add.eo \
-tests/eolian/data/object_impl_add_ref.c
+tests/eolian/data/object_impl_add_ref.c \
+tests/eolian/data/consts.eo
 
diff --git a/src/tests/eolian/data/consts.eo b/src/tests/eolian/data/consts.eo
new file mode 100644 (file)
index 0000000..b139317
--- /dev/null
@@ -0,0 +1,28 @@
+class Const {
+   properties {
+      a {
+         set {
+            return Eina_Bool (EINA_TRUE); /*@ comment for property set return */
+         }
+         get {
+            buffer: const;
+         }
+         values {
+            int value; /*@ Value description */
+            char *buffer;
+         }
+      }
+   }
+   methods {
+      foo {
+         /*@ comment foo */
+         params {
+            @in int a; /*@ a */
+            @inout char *b;
+            @out double c;
+         }
+         const;
+         return char *(NULL); /*@ comment for method return */
+      }
+   }
+};
index 2f9afc94166aec4bf4a405ff3c9efb8fc91afd8e..3589c88d51b11234fc238ad67564e672cce49cc5 100644 (file)
@@ -9,6 +9,33 @@
 #include "Eolian.h"
 #include "eolian_suite.h"
 
+START_TEST(eolian_consts)
+{
+   Eolian_Function fid = NULL;
+   const char *class_name = "Const";
+   Eolian_Function_Parameter param = NULL;
+
+   eolian_init();
+   /* Parsing */
+   fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/consts.eo"));
+
+   /* Class */
+   fail_if(!eolian_class_exists(class_name));
+
+   /* Property */
+   fail_if(!(fid = eolian_class_function_find_by_name(class_name, "a", EOLIAN_PROPERTY)));
+   fail_if(!(param = eolian_function_parameter_get(fid, "buffer")));
+   fail_if(eolian_parameter_const_attribute_get(param, EINA_FALSE));
+   fail_if(!eolian_parameter_const_attribute_get(param, EINA_TRUE));
+
+   /* Method */
+   fail_if(!(fid = eolian_class_function_find_by_name(class_name, "foo", EOLIAN_METHOD)));
+   fail_if(EINA_FALSE == eolian_function_object_is_const(fid));
+
+   eolian_shutdown();
+}
+END_TEST
+
 START_TEST(eolian_ctor_dtor)
 {
    const char *class_name = "Ctor_Dtor";
@@ -277,5 +304,6 @@ void eolian_parsing_test(TCase *tc)
    tcase_add_test(tc, eolian_scope);
    tcase_add_test(tc, eolian_complex_type);
    tcase_add_test(tc, eolian_typedef);
+   tcase_add_test(tc, eolian_consts);
 }