summaryrefslogtreecommitdiff
path: root/src/tests/eet
diff options
context:
space:
mode:
authorJee-Yong Um <jc9.um@samsung.com>2016-05-10 15:18:33 -0700
committerCedric Bail <cedric@osg.samsung.com>2016-05-10 16:36:22 -0700
commit557381a070d818aa2353a0785a0d20bb6406afaf (patch)
tree23235a627f35f8a7f3e0c14bd11da565bea1c1de /src/tests/eet
parentfa5abb2967ca1a14770c5270b13200412a0fd345 (diff)
eet: add a helper to setup hash with generic value storage
Summary: add a macro to setup eet_data_descriptor for hash with generic value storage. Test Plan: make check (test case is included in eet test suite) Reviewers: cedric, raster Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D3925 Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/eet')
-rw-r--r--src/tests/eet/eet_test_data.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/tests/eet/eet_test_data.c b/src/tests/eet/eet_test_data.c
index 60ec02761c..4899832392 100644
--- a/src/tests/eet/eet_test_data.c
+++ b/src/tests/eet/eet_test_data.c
@@ -18,6 +18,7 @@ typedef struct _Eet_St1 Eet_St1;
18typedef struct _Eet_St2 Eet_St2; 18typedef struct _Eet_St2 Eet_St2;
19typedef struct _Eet_St3 Eet_St3; 19typedef struct _Eet_St3 Eet_St3;
20typedef struct _Eet_List Eet_List; 20typedef struct _Eet_List Eet_List;
21typedef struct _Eet_Hash Eet_Hash;
21 22
22typedef enum _Eet_Union 23typedef enum _Eet_Union
23{ 24{
@@ -102,6 +103,11 @@ struct _Eet_List
102 Eina_List *list; 103 Eina_List *list;
103}; 104};
104 105
106struct _Eet_Hash
107{
108 Eina_Hash *hash;
109};
110
105static const char * 111static const char *
106_eet_union_type_get(const void *data, 112_eet_union_type_get(const void *data,
107 Eina_Bool *unknow) 113 Eina_Bool *unknow)
@@ -752,6 +758,64 @@ START_TEST(eet_test_data_variant)
752} /* START_TEST */ 758} /* START_TEST */
753END_TEST 759END_TEST
754 760
761START_TEST(eet_test_data_hash_value)
762{
763 Eet_Hash *h;
764 Eina_Value *val;
765 Eet_Data_Descriptor_Class eddc;
766 Eet_Data_Descriptor *edd;
767 void *blob;
768 int size;
769 int i;
770 double d;
771 char *s;
772
773 eina_init();
774 eet_init();
775
776 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Hash);
777 edd = eet_data_descriptor_stream_new(&eddc);
778
779 EET_DATA_DESCRIPTOR_ADD_HASH_VALUE(edd, Eet_Hash, "hash", hash);
780
781 h = calloc(1, sizeof(Eet_Hash));
782 h->hash = eina_hash_string_small_new((Eina_Free_Cb)eina_value_free);
783
784 val = eina_value_new(EINA_VALUE_TYPE_INT);
785 eina_value_set(val, EET_TEST_INT);
786 eina_hash_direct_add(h->hash, "val/int", val);
787
788 val = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
789 eina_value_set(val, EET_TEST_DOUBLE);
790 eina_hash_direct_add(h->hash, "val/double", val);
791
792 val = eina_value_new(EINA_VALUE_TYPE_STRING);
793 eina_value_set(val, EET_TEST_STRING);
794 eina_hash_direct_add(h->hash, "val/string", val);
795
796 blob = eet_data_descriptor_encode(edd, h, &size);
797 fail_if((!blob) || (size <= 0));
798
799 h = eet_data_descriptor_decode(edd, blob, size);
800 fail_if(!h);
801
802 val = (Eina_Value *)eina_hash_find(h->hash, "val/int");
803 eina_value_get(val, &i);
804 fail_if((!val) || (i != EET_TEST_INT));
805
806 val = (Eina_Value *)eina_hash_find(h->hash, "val/double");
807 eina_value_get(val, &d);
808 fail_if((!val) || (d != EET_TEST_DOUBLE));
809
810 val = (Eina_Value *)eina_hash_find(h->hash, "val/string");
811 eina_value_get(val, &s);
812 fail_if((!val) || strcmp(s, EET_TEST_STRING));
813
814 eet_shutdown();
815 eina_shutdown();
816} /* START_TEST */
817END_TEST
818
755void eet_test_data(TCase *tc) 819void eet_test_data(TCase *tc)
756{ 820{
757 tcase_add_test(tc, eet_test_data_basic_type_encoding_decoding); 821 tcase_add_test(tc, eet_test_data_basic_type_encoding_decoding);
@@ -761,4 +825,5 @@ void eet_test_data(TCase *tc)
761 tcase_add_test(tc, eet_test_data_fp); 825 tcase_add_test(tc, eet_test_data_fp);
762 tcase_add_test(tc, eet_test_data_union); 826 tcase_add_test(tc, eet_test_data_union);
763 tcase_add_test(tc, eet_test_data_variant); 827 tcase_add_test(tc, eet_test_data_variant);
828 tcase_add_test(tc, eet_test_data_hash_value);
764} 829}