summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-13 17:26:26 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-13 17:26:26 -0700
commitcacd374e4121f5e91db51cf7b228f243d04d3193 (patch)
treefd4fa96e3f9558749b0f3db42de24fba90ec0c52 /src
parent8fbfab83e9c580a25537a2eefa6f63ef313f3089 (diff)
eina: add tests for eina_value_to_binbuf.
Diffstat (limited to 'src')
-rw-r--r--src/tests/eina/eina_test_value.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/tests/eina/eina_test_value.c b/src/tests/eina/eina_test_value.c
index 9bdcc4c120..15cf35888e 100644
--- a/src/tests/eina/eina_test_value.c
+++ b/src/tests/eina/eina_test_value.c
@@ -799,6 +799,70 @@ START_TEST(eina_value_test_to_string)
799} 799}
800END_TEST 800END_TEST
801 801
802START_TEST(eina_value_test_to_binbuf)
803{
804 Eina_Value *value;
805 char c, in_c;
806 const char *str, *in_str;
807 Eina_Binbuf *bin;
808 const char *out;
809 char buf[256];
810
811 eina_init();
812
813 value = eina_value_new(EINA_VALUE_TYPE_CHAR);
814 fail_unless(value != NULL);
815 in_c = 'x';
816 fail_unless(eina_value_pset(value, &in_c));
817 fail_unless(eina_value_pget(value, &c));
818 fail_unless(c == 'x');
819 snprintf(buf, sizeof(buf), "%c", in_c);
820 bin = eina_value_to_binbuf(value);
821 out = (char *) eina_binbuf_string_get(bin);
822 fail_unless(out != NULL);
823 ck_assert_str_eq(buf, out);
824 eina_binbuf_free(bin);
825 eina_value_flush(value);
826
827 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
828 in_str = "hello world!";
829 fail_unless(eina_value_pset(value, &in_str));
830 fail_unless(eina_value_pget(value, &str));
831 ck_assert_str_eq(str, "hello world!");
832 bin = eina_value_to_binbuf(value);
833 out = (char *) eina_binbuf_string_get(bin);
834 fail_unless(out != NULL);
835 ck_assert_str_eq(in_str, out);
836 eina_binbuf_free(bin);
837
838 in_str = "eina-value";
839 fail_unless(eina_value_pset(value, &in_str));
840 fail_unless(eina_value_pget(value, &str));
841 ck_assert_str_eq(str, "eina-value");
842 bin = eina_value_to_binbuf(value);
843 out = (char *) eina_binbuf_string_get(bin);
844 fail_unless(out != NULL);
845 ck_assert_str_eq(in_str, out);
846 eina_binbuf_free(bin);
847
848 eina_value_flush(value);
849 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
850
851 in_str = "profusion";
852 fail_unless(eina_value_pset(value, &in_str));
853 fail_unless(eina_value_pget(value, &str));
854 ck_assert_str_eq(str, "profusion");
855 bin = eina_value_to_binbuf(value);
856 out = (char *) eina_binbuf_string_get(bin);
857 fail_unless(out != NULL);
858 ck_assert_str_eq(in_str, out);
859 eina_binbuf_free(bin);
860
861 eina_value_free(value);
862 eina_shutdown();
863}
864END_TEST
865
802START_TEST(eina_value_test_convert_char) 866START_TEST(eina_value_test_convert_char)
803{ 867{
804 Eina_Value *value, conv; 868 Eina_Value *value, conv;
@@ -2948,6 +3012,7 @@ eina_test_value(TCase *tc)
2948 tcase_add_test(tc, eina_value_test_pvariant); 3012 tcase_add_test(tc, eina_value_test_pvariant);
2949 tcase_add_test(tc, eina_value_test_compare); 3013 tcase_add_test(tc, eina_value_test_compare);
2950 tcase_add_test(tc, eina_value_test_to_string); 3014 tcase_add_test(tc, eina_value_test_to_string);
3015 tcase_add_test(tc, eina_value_test_to_binbuf);
2951 tcase_add_test(tc, eina_value_test_convert_char); 3016 tcase_add_test(tc, eina_value_test_convert_char);
2952 tcase_add_test(tc, eina_value_test_convert_uchar); 3017 tcase_add_test(tc, eina_value_test_convert_uchar);
2953 tcase_add_test(tc, eina_value_test_convert_short); 3018 tcase_add_test(tc, eina_value_test_convert_short);