diff options
Diffstat (limited to 'libraries/eina/src/tests/eina_test_binbuf.c')
-rw-r--r-- | libraries/eina/src/tests/eina_test_binbuf.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/libraries/eina/src/tests/eina_test_binbuf.c b/libraries/eina/src/tests/eina_test_binbuf.c index 713e078..d62072e 100644 --- a/libraries/eina/src/tests/eina_test_binbuf.c +++ b/libraries/eina/src/tests/eina_test_binbuf.c | |||
@@ -27,8 +27,8 @@ | |||
27 | START_TEST(binbuf_simple) | 27 | START_TEST(binbuf_simple) |
28 | { | 28 | { |
29 | Eina_Binbuf *buf; | 29 | Eina_Binbuf *buf; |
30 | char *txt; | 30 | unsigned char *txt; |
31 | const char cbuf[] = "Null in the middle \0 and more text afterwards and \0 anotehr null just there and another one \0 here."; | 31 | const unsigned char cbuf[] = "Null in the middle \0 and more text afterwards and \0 anotehr null just there and another one \0 here."; |
32 | size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ | 32 | size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ |
33 | 33 | ||
34 | 34 | ||
@@ -69,7 +69,7 @@ END_TEST | |||
69 | START_TEST(binbuf_remove) | 69 | START_TEST(binbuf_remove) |
70 | { | 70 | { |
71 | Eina_Binbuf *buf; | 71 | Eina_Binbuf *buf; |
72 | const char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!"; | 72 | const unsigned char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!"; |
73 | size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ | 73 | size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ |
74 | 74 | ||
75 | eina_init(); | 75 | eina_init(); |
@@ -98,6 +98,33 @@ START_TEST(binbuf_remove) | |||
98 | } | 98 | } |
99 | END_TEST | 99 | END_TEST |
100 | 100 | ||
101 | START_TEST(binbuf_manage_simple) | ||
102 | { | ||
103 | Eina_Binbuf *buf; | ||
104 | const char *_cbuf = "12\0 456 78\0 abcthis is some more random junk here!"; | ||
105 | const unsigned char *cbuf = (const unsigned char *) _cbuf; | ||
106 | size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ | ||
107 | unsigned char *alloc_buf = malloc(size); | ||
108 | memcpy(alloc_buf, cbuf, size); | ||
109 | |||
110 | eina_init(); | ||
111 | |||
112 | buf = eina_binbuf_manage_new_length(alloc_buf, size); | ||
113 | fail_if(!buf); | ||
114 | |||
115 | fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size)); | ||
116 | fail_if(size != eina_binbuf_length_get(buf)); | ||
117 | eina_binbuf_append_length(buf, cbuf, size); | ||
118 | fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size)); | ||
119 | fail_if(memcmp(eina_binbuf_string_get(buf) + size, cbuf, size)); | ||
120 | fail_if(2 * size != eina_binbuf_length_get(buf)); | ||
121 | |||
122 | eina_binbuf_free(buf); | ||
123 | |||
124 | eina_shutdown(); | ||
125 | } | ||
126 | END_TEST | ||
127 | |||
101 | START_TEST(binbuf_insert) | 128 | START_TEST(binbuf_insert) |
102 | { | 129 | { |
103 | #if 0 | 130 | #if 0 |
@@ -154,7 +181,7 @@ END_TEST | |||
154 | START_TEST(binbuf_realloc) | 181 | START_TEST(binbuf_realloc) |
155 | { | 182 | { |
156 | Eina_Binbuf *buf; | 183 | Eina_Binbuf *buf; |
157 | char pattern[1024 * 16]; | 184 | unsigned char pattern[1024 * 16]; |
158 | unsigned int i; | 185 | unsigned int i; |
159 | size_t sz; | 186 | size_t sz; |
160 | 187 | ||
@@ -232,4 +259,5 @@ eina_test_binbuf(TCase *tc) | |||
232 | tcase_add_test(tc, binbuf_remove); | 259 | tcase_add_test(tc, binbuf_remove); |
233 | tcase_add_test(tc, binbuf_insert); | 260 | tcase_add_test(tc, binbuf_insert); |
234 | tcase_add_test(tc, binbuf_realloc); | 261 | tcase_add_test(tc, binbuf_realloc); |
262 | tcase_add_test(tc, binbuf_manage_simple); | ||
235 | } | 263 | } |