forked from enlightenment/efl
parent
b49d61f502
commit
0ed3fb726b
|
@ -25,18 +25,66 @@
|
|||
#include "eina_suite.h"
|
||||
#include "Eina.h"
|
||||
|
||||
START_TEST(eina_strbuf_simple)
|
||||
START_TEST(strbuf_simple)
|
||||
{
|
||||
Eina_Strbuf *buf;
|
||||
char text[] = "This test should be so long that it is longer than the initial size of strbuf";
|
||||
char *txt;
|
||||
#define TEXT "This test should be so long that it is longer than the initial size of strbuf"
|
||||
|
||||
eina_init();
|
||||
|
||||
buf = eina_strbuf_new();
|
||||
fail_if(!buf);
|
||||
|
||||
eina_strbuf_append(buf, text);
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), text));
|
||||
eina_strbuf_append(buf, TEXT);
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), TEXT));
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
eina_strbuf_append(buf, TEXT);
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), TEXT TEXT));
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
txt = eina_strbuf_string_steal(buf);
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
fail_if(strcmp(txt, TEXT TEXT));
|
||||
free(txt);
|
||||
fail_if(eina_strbuf_length_get(buf) != 0);
|
||||
fail_if(!strcmp(eina_strbuf_string_get(buf), TEXT TEXT));
|
||||
eina_strbuf_append(buf, TEXT);
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
eina_strbuf_reset(buf);
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
fail_if(eina_strbuf_length_get(buf) != 0);
|
||||
fail_if(!strcmp(eina_strbuf_string_get(buf), TEXT));
|
||||
|
||||
eina_strbuf_free(buf);
|
||||
|
||||
eina_shutdown();
|
||||
#undef TEXT
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(strbuf_remove)
|
||||
{
|
||||
Eina_Strbuf *buf;
|
||||
|
||||
eina_init();
|
||||
|
||||
buf = eina_strbuf_new();
|
||||
fail_if(!buf);
|
||||
|
||||
eina_strbuf_append(buf, "123 456 789 abc");
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
eina_strbuf_remove(buf, 0, 4);
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), "456 789 abc"));
|
||||
eina_strbuf_remove(buf, 8, 1000);
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), "456 789 "));
|
||||
eina_strbuf_remove(buf, 7, eina_strbuf_length_get(buf));
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), "456 789"));
|
||||
eina_strbuf_remove(buf, 2, 4);
|
||||
fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
|
||||
fail_if(strcmp(eina_strbuf_string_get(buf), "45789"));
|
||||
|
||||
eina_strbuf_free(buf);
|
||||
|
||||
|
@ -47,5 +95,6 @@ END_TEST
|
|||
void
|
||||
eina_test_strbuf(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eina_strbuf_simple);
|
||||
tcase_add_test(tc, strbuf_simple);
|
||||
tcase_add_test(tc, strbuf_remove);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue