summaryrefslogtreecommitdiff
path: root/src/tests/eet
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-07-15 17:02:53 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-07-15 17:04:34 +0900
commitd9aa0fccd9b03f022a1480345932146adb97cfa7 (patch)
treeae0740c9bfadc9feb616cec04fda808336ba390d /src/tests/eet
parent4a183ac1a8a6c80f3cbfb5ffb4b1507da5dda642 (diff)
eet: add support for EET_T_VALUE.
Add the moment, it only support simple type. Need iterator for more complex type. It also expect a pointer to an Eina_Value and not directly an Eina_Value, let me know if you prefer the opposite and maybe I should rename it EET_T_PVALUE.
Diffstat (limited to 'src/tests/eet')
-rw-r--r--src/tests/eet/eet_suite.c65
1 files changed, 48 insertions, 17 deletions
diff --git a/src/tests/eet/eet_suite.c b/src/tests/eet/eet_suite.c
index db16719837..6bc5687180 100644
--- a/src/tests/eet/eet_suite.c
+++ b/src/tests/eet/eet_suite.c
@@ -51,6 +51,7 @@ struct _Eet_Test_Basic_Type
51 unsigned short us; 51 unsigned short us;
52 unsigned int ui; 52 unsigned int ui;
53 unsigned long long ul; 53 unsigned long long ul;
54 Eina_Value *vp;
54 Eet_Test_Basic_Type *empty; 55 Eet_Test_Basic_Type *empty;
55 Eet_Test_Basic_Type *with; 56 Eet_Test_Basic_Type *with;
56}; 57};
@@ -145,6 +146,8 @@ _eet_test_basic_set(Eet_Test_Basic_Type *res,
145 res->ul = EET_TEST_LONG_LONG; 146 res->ul = EET_TEST_LONG_LONG;
146 res->empty = NULL; 147 res->empty = NULL;
147 res->with = NULL; 148 res->with = NULL;
149 res->vp = eina_value_new(EINA_VALUE_TYPE_INT);
150 eina_value_set(res->vp, EET_TEST_INT + i);
148 151
149 if (i == 0) 152 if (i == 0)
150 { 153 {
@@ -169,13 +172,16 @@ _eet_test_basic_set(Eet_Test_Basic_Type *res,
169 tmp->ul = EET_TEST_LONG_LONG; 172 tmp->ul = EET_TEST_LONG_LONG;
170 tmp->empty = NULL; 173 tmp->empty = NULL;
171 tmp->with = NULL; 174 tmp->with = NULL;
175 tmp->vp = NULL;
172 } 176 }
173} /* _eet_test_basic_set */ 177} /* _eet_test_basic_set */
174 178
175static void 179static void
176_eet_test_basic_check(Eet_Test_Basic_Type *result, 180_eet_test_basic_check(Eet_Test_Basic_Type *result,
177 int i) 181 int i,
182 Eina_Bool dumper)
178{ 183{
184 int test = -1;
179 float tmp; 185 float tmp;
180 186
181 fail_if(result->c != EET_TEST_CHAR); 187 fail_if(result->c != EET_TEST_CHAR);
@@ -188,6 +194,16 @@ _eet_test_basic_check(Eet_Test_Basic_Type *result,
188 fail_if(result->us != EET_TEST_SHORT); 194 fail_if(result->us != EET_TEST_SHORT);
189 fail_if(result->ui != EET_TEST_INT); 195 fail_if(result->ui != EET_TEST_INT);
190 fail_if(result->ul != EET_TEST_LONG_LONG); 196 fail_if(result->ul != EET_TEST_LONG_LONG);
197 if (!dumper)
198 {
199 fail_if(result->vp == NULL);
200 eina_value_get(result->vp, &test);
201 fail_if(test != EET_TEST_INT + i);
202 }
203 else
204 {
205 fail_if(result->vp != NULL);
206 }
191 207
192 tmp = (result->f1 + EET_TEST_FLOAT); 208 tmp = (result->f1 + EET_TEST_FLOAT);
193 if (tmp < 0) 209 if (tmp < 0)
@@ -225,6 +241,7 @@ _eet_test_basic_check(Eet_Test_Basic_Type *result,
225 fail_if(tmp2->us != EET_TEST_SHORT); 241 fail_if(tmp2->us != EET_TEST_SHORT);
226 fail_if(tmp2->ui != EET_TEST_INT); 242 fail_if(tmp2->ui != EET_TEST_INT);
227 fail_if(tmp2->ul != EET_TEST_LONG_LONG); 243 fail_if(tmp2->ul != EET_TEST_LONG_LONG);
244 fail_if(tmp2->vp != NULL);
228 } 245 }
229 else 246 else
230 fail_if(result->with != NULL); 247 fail_if(result->with != NULL);
@@ -298,6 +315,11 @@ _eet_build_basic_descriptor(Eet_Data_Descriptor *edd)
298 "ul", 315 "ul",
299 ul, 316 ul,
300 EET_T_ULONG_LONG); 317 EET_T_ULONG_LONG);
318 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
319 Eet_Test_Basic_Type,
320 "vp",
321 vp,
322 EET_T_VALUE);
301 323
302 EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "empty", empty, edd); 324 EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "empty", empty, edd);
303 EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "with", with, edd); 325 EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "with", with, edd);
@@ -331,7 +353,7 @@ START_TEST(eet_test_basic_data_type_encoding_decoding)
331 result = eet_data_descriptor_decode(edd, transfert, size); 353 result = eet_data_descriptor_decode(edd, transfert, size);
332 fail_if(!result); 354 fail_if(!result);
333 355
334 _eet_test_basic_check(result, 0); 356 _eet_test_basic_check(result, 0, EINA_FALSE);
335 357
336 free(result->str); 358 free(result->str);
337 free(result); 359 free(result);
@@ -598,7 +620,8 @@ _eet_test_ex_set(Eet_Test_Ex_Type *res,
598 620
599static int 621static int
600_eet_test_ex_check(Eet_Test_Ex_Type *stuff, 622_eet_test_ex_check(Eet_Test_Ex_Type *stuff,
601 int offset) 623 int offset,
624 Eina_Bool dumper)
602{ 625{
603 double tmp; 626 double tmp;
604 unsigned int i; 627 unsigned int i;
@@ -680,13 +703,15 @@ _eet_test_ex_check(Eet_Test_Ex_Type *stuff,
680 703
681 for (i = 0; i < 10; ++i) 704 for (i = 0; i < 10; ++i)
682 { 705 {
683 _eet_test_basic_check(stuff->sarray1 + i, i); 706 _eet_test_basic_check(stuff->sarray1 + i, i, dumper);
684 _eet_test_basic_check(stuff->varray2 + i, i); 707 _eet_test_basic_check(stuff->varray2 + i, i, dumper);
685 } 708 }
686 709
687 return 0; 710 return 0;
688} /* _eet_test_ex_check */ 711} /* _eet_test_ex_check */
689 712
713static Eina_Bool _dump_call = EINA_FALSE;
714
690static Eina_Bool 715static Eina_Bool
691func(EINA_UNUSED const Eina_Hash *hash, 716func(EINA_UNUSED const Eina_Hash *hash,
692 const void *key, 717 const void *key,
@@ -699,7 +724,7 @@ func(EINA_UNUSED const Eina_Hash *hash,
699 && strcmp(key, EET_TEST_KEY2) != 0) 724 && strcmp(key, EET_TEST_KEY2) != 0)
700 *res = 1; 725 *res = 1;
701 726
702 if (_eet_test_ex_check(data, 2)) 727 if (_eet_test_ex_check(data, 2, _dump_call))
703 *res = 1; 728 *res = 1;
704 729
705 return EINA_TRUE; 730 return EINA_TRUE;
@@ -765,8 +790,8 @@ START_TEST(eet_test_data_type_encoding_decoding)
765 result = eet_data_descriptor_decode(edd, transfert, size); 790 result = eet_data_descriptor_decode(edd, transfert, size);
766 fail_if(!result); 791 fail_if(!result);
767 792
768 fail_if(_eet_test_ex_check(result, 0) != 0); 793 fail_if(_eet_test_ex_check(result, 0, EINA_FALSE) != 0);
769 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0); 794 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_FALSE) != 0);
770 fail_if(eina_list_data_get(result->ilist) == NULL); 795 fail_if(eina_list_data_get(result->ilist) == NULL);
771 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); 796 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
772 fail_if(eina_list_data_get(result->slist) == NULL); 797 fail_if(eina_list_data_get(result->slist) == NULL);
@@ -870,8 +895,8 @@ START_TEST(eet_test_data_type_dump_undump)
870 result = eet_data_descriptor_decode(edd, transfert2, size2); 895 result = eet_data_descriptor_decode(edd, transfert2, size2);
871 fail_if(!result); 896 fail_if(!result);
872 897
873 fail_if(_eet_test_ex_check(result, 0) != 0); 898 fail_if(_eet_test_ex_check(result, 0, EINA_TRUE) != 0);
874 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0); 899 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_TRUE) != 0);
875 fail_if(eina_list_data_get(result->ilist) == NULL); 900 fail_if(eina_list_data_get(result->ilist) == NULL);
876 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); 901 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
877 fail_if(eina_list_data_get(result->slist) == NULL); 902 fail_if(eina_list_data_get(result->slist) == NULL);
@@ -881,8 +906,10 @@ START_TEST(eet_test_data_type_dump_undump)
881 fail_if(strcmp(result->charray[0], "test") != 0); 906 fail_if(strcmp(result->charray[0], "test") != 0);
882 907
883 test = 0; 908 test = 0;
909 _dump_call = EINA_TRUE;
884 if (result->hash) 910 if (result->hash)
885 eina_hash_foreach(result->hash, func, &test); 911 eina_hash_foreach(result->hash, func, &test);
912 _dump_call = EINA_FALSE;
886 913
887 fail_if(test != 0); 914 fail_if(test != 0);
888 if (result->ihash) 915 if (result->ihash)
@@ -1039,7 +1066,7 @@ START_TEST(eet_file_data_test)
1039 fail_if(!result); 1066 fail_if(!result);
1040 1067
1041 /* Test the resulting data. */ 1068 /* Test the resulting data. */
1042 fail_if(_eet_test_ex_check(result, 0) != 0); 1069 fail_if(_eet_test_ex_check(result, 0, EINA_FALSE) != 0);
1043 1070
1044 eet_close(ef); 1071 eet_close(ef);
1045 1072
@@ -1060,8 +1087,8 @@ START_TEST(eet_file_data_test)
1060 fail_if(eet_dictionary_string_check(ed, result->istr)); 1087 fail_if(eet_dictionary_string_check(ed, result->istr));
1061 1088
1062 /* Test the resulting data. */ 1089 /* Test the resulting data. */
1063 fail_if(_eet_test_ex_check(result, 0) != 0); 1090 fail_if(_eet_test_ex_check(result, 0, EINA_FALSE) != 0);
1064 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0); 1091 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_FALSE) != 0);
1065 fail_if(eina_list_data_get(result->ilist) == NULL); 1092 fail_if(eina_list_data_get(result->ilist) == NULL);
1066 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); 1093 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
1067 fail_if(eina_list_data_get(result->slist) == NULL); 1094 fail_if(eina_list_data_get(result->slist) == NULL);
@@ -1186,8 +1213,8 @@ START_TEST(eet_file_data_dump_test)
1186 eet_close(ef); 1213 eet_close(ef);
1187 1214
1188 /* Test the resulting data. */ 1215 /* Test the resulting data. */
1189 fail_if(_eet_test_ex_check(result, 0) != 0); 1216 fail_if(_eet_test_ex_check(result, 0, EINA_TRUE) != 0);
1190 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0); 1217 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_TRUE) != 0);
1191 fail_if(eina_list_data_get(result->ilist) == NULL); 1218 fail_if(eina_list_data_get(result->ilist) == NULL);
1192 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); 1219 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
1193 fail_if(eina_list_data_get(result->slist) == NULL); 1220 fail_if(eina_list_data_get(result->slist) == NULL);
@@ -1197,8 +1224,10 @@ START_TEST(eet_file_data_dump_test)
1197 fail_if(strcmp(result->charray[0], "test") != 0); 1224 fail_if(strcmp(result->charray[0], "test") != 0);
1198 1225
1199 test = 0; 1226 test = 0;
1227 _dump_call = EINA_TRUE;
1200 if (result->hash) 1228 if (result->hash)
1201 eina_hash_foreach(result->hash, func, &test); 1229 eina_hash_foreach(result->hash, func, &test);
1230 _dump_call = EINA_FALSE;
1202 1231
1203 fail_if(test != 0); 1232 fail_if(test != 0);
1204 if (result->ihash) 1233 if (result->ihash)
@@ -1961,8 +1990,8 @@ _eet_connection_read(const void *eet_data,
1961 1990
1962 /* Test the resulting data. */ 1991 /* Test the resulting data. */
1963 fail_if(!node); 1992 fail_if(!node);
1964 fail_if(_eet_test_ex_check(result, 0) != 0); 1993 fail_if(_eet_test_ex_check(result, 0, _dump_call) != 0);
1965 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0); 1994 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1, _dump_call) != 0);
1966 fail_if(eina_list_data_get(result->ilist) == NULL); 1995 fail_if(eina_list_data_get(result->ilist) == NULL);
1967 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); 1996 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
1968 fail_if(eina_list_data_get(result->slist) == NULL); 1997 fail_if(eina_list_data_get(result->slist) == NULL);
@@ -1984,7 +2013,9 @@ _eet_connection_read(const void *eet_data,
1984 if (!dt->test) 2013 if (!dt->test)
1985 { 2014 {
1986 dt->test = EINA_TRUE; 2015 dt->test = EINA_TRUE;
2016 _dump_call = EINA_TRUE;
1987 fail_if(!eet_connection_node_send(dt->conn, node, NULL)); 2017 fail_if(!eet_connection_node_send(dt->conn, node, NULL));
2018 _dump_call = EINA_FALSE;
1988 } 2019 }
1989 2020
1990 return EINA_TRUE; 2021 return EINA_TRUE;