From 825a3d837a33f226c879cd02ad15c3fba57e8b2c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 23 Jan 2012 23:30:42 +1000 Subject: Update the EFL to what I'm actually using, coz I'm using some stuff not yet released. --- libraries/eina/src/tests/eina_test_binbuf.c | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'libraries/eina/src/tests/eina_test_binbuf.c') 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 @@ START_TEST(binbuf_simple) { Eina_Binbuf *buf; - char *txt; - const char cbuf[] = "Null in the middle \0 and more text afterwards and \0 anotehr null just there and another one \0 here."; + unsigned char *txt; + const unsigned char cbuf[] = "Null in the middle \0 and more text afterwards and \0 anotehr null just there and another one \0 here."; size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ @@ -69,7 +69,7 @@ END_TEST START_TEST(binbuf_remove) { Eina_Binbuf *buf; - const char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!"; + const unsigned char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!"; size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ eina_init(); @@ -98,6 +98,33 @@ START_TEST(binbuf_remove) } END_TEST +START_TEST(binbuf_manage_simple) +{ + Eina_Binbuf *buf; + const char *_cbuf = "12\0 456 78\0 abcthis is some more random junk here!"; + const unsigned char *cbuf = (const unsigned char *) _cbuf; + size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ + unsigned char *alloc_buf = malloc(size); + memcpy(alloc_buf, cbuf, size); + + eina_init(); + + buf = eina_binbuf_manage_new_length(alloc_buf, size); + fail_if(!buf); + + fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size)); + fail_if(size != eina_binbuf_length_get(buf)); + eina_binbuf_append_length(buf, cbuf, size); + fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size)); + fail_if(memcmp(eina_binbuf_string_get(buf) + size, cbuf, size)); + fail_if(2 * size != eina_binbuf_length_get(buf)); + + eina_binbuf_free(buf); + + eina_shutdown(); +} +END_TEST + START_TEST(binbuf_insert) { #if 0 @@ -154,7 +181,7 @@ END_TEST START_TEST(binbuf_realloc) { Eina_Binbuf *buf; - char pattern[1024 * 16]; + unsigned char pattern[1024 * 16]; unsigned int i; size_t sz; @@ -232,4 +259,5 @@ eina_test_binbuf(TCase *tc) tcase_add_test(tc, binbuf_remove); tcase_add_test(tc, binbuf_insert); tcase_add_test(tc, binbuf_realloc); + tcase_add_test(tc, binbuf_manage_simple); } -- cgit v1.1