summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-02-12 13:42:57 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2015-02-12 13:42:57 +0000
commit687e5130d852eb48eb7a1542bcb3a918cf4fb0a7 (patch)
treea2742329effeec292810d591839bc280e8af4316
parenta2dd62e510441b8cf8521e8a8f105ae5c6e6d512 (diff)
eolian: add testcase for nullable/optional
-rw-r--r--src/tests/eolian/data/null.eo12
-rw-r--r--src/tests/eolian/eolian_parsing.c39
2 files changed, 51 insertions, 0 deletions
diff --git a/src/tests/eolian/data/null.eo b/src/tests/eolian/data/null.eo
new file mode 100644
index 0000000000..08499a5637
--- /dev/null
+++ b/src/tests/eolian/data/null.eo
@@ -0,0 +1,12 @@
1class Null {
2 methods {
3 foo {
4 params {
5 char *x;
6 char *y @nullable;
7 char *z @optional;
8 char *w @optional @nullable;
9 }
10 }
11 }
12}
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 824f9fcab5..f1e30f25a8 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -986,6 +986,44 @@ START_TEST(eolian_free_func)
986} 986}
987END_TEST 987END_TEST
988 988
989START_TEST(eolian_null)
990{
991 const Eolian_Class *class;
992 const Eolian_Function *func;
993 const Eolian_Function_Parameter *param;
994
995 eolian_init();
996
997 /* Parsing */
998 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/null.eo"));
999
1000 fail_if(!(class = eolian_class_get_by_name("Null")));
1001 fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
1002
1003 /* no qualifiers */
1004 fail_if(!(param = eolian_function_parameter_get_by_name(func, "x")));
1005 fail_if(eolian_parameter_is_nullable(param));
1006 fail_if(eolian_parameter_is_optional(param));
1007
1008 /* nullable */
1009 fail_if(!(param = eolian_function_parameter_get_by_name(func, "y")));
1010 fail_if(!eolian_parameter_is_nullable(param));
1011 fail_if(eolian_parameter_is_optional(param));
1012
1013 /* optional */
1014 fail_if(!(param = eolian_function_parameter_get_by_name(func, "z")));
1015 fail_if(eolian_parameter_is_nullable(param));
1016 fail_if(!eolian_parameter_is_optional(param));
1017
1018 /* both */
1019 fail_if(!(param = eolian_function_parameter_get_by_name(func, "w")));
1020 fail_if(!eolian_parameter_is_nullable(param));
1021 fail_if(!eolian_parameter_is_optional(param));
1022
1023 eolian_shutdown();
1024}
1025END_TEST
1026
989void eolian_parsing_test(TCase *tc) 1027void eolian_parsing_test(TCase *tc)
990{ 1028{
991 tcase_add_test(tc, eolian_simple_parsing); 1029 tcase_add_test(tc, eolian_simple_parsing);
@@ -1003,5 +1041,6 @@ void eolian_parsing_test(TCase *tc)
1003 tcase_add_test(tc, eolian_enum); 1041 tcase_add_test(tc, eolian_enum);
1004 tcase_add_test(tc, eolian_class_funcs); 1042 tcase_add_test(tc, eolian_class_funcs);
1005 tcase_add_test(tc, eolian_free_func); 1043 tcase_add_test(tc, eolian_free_func);
1044 tcase_add_test(tc, eolian_null);
1006} 1045}
1007 1046