-utc_eina_binbuf_append_buffer.c
-utc_eina_binbuf_append_char.c
-utc_eina_binbuf_append_length.c
-utc_eina_binbuf_free.c
-utc_eina_binbuf_insert_char.c
-utc_eina_binbuf_insert_length.c
-utc_eina_binbuf_length_get.c
-utc_eina_binbuf_manage_new.c
-utc_eina_binbuf_manage_new_length.c
-utc_eina_binbuf_new.c
-utc_eina_binbuf_remove.c
-utc_eina_binbuf_reset.c
-utc_eina_binbuf_string_free.c
-utc_eina_binbuf_string_get.c
-utc_eina_binbuf_string_steal.c
+utc_eina_binbuf.c
-utc_eina_binbuf_append_buffer.c
-utc_eina_binbuf_append_char.c
-utc_eina_binbuf_append_length.c
-utc_eina_binbuf_free.c
-utc_eina_binbuf_insert_char.c
-utc_eina_binbuf_insert_length.c
-utc_eina_binbuf_length_get.c
-utc_eina_binbuf_manage_new.c
-utc_eina_binbuf_manage_new_length.c
-utc_eina_binbuf_new.c
-utc_eina_binbuf_remove.c
-utc_eina_binbuf_reset.c
-utc_eina_binbuf_string_free.c
-utc_eina_binbuf_string_get.c
-utc_eina_binbuf_string_steal.c
+utc_eina_binbuf.c
-#utc_eina_binbuf_append_buffer.c
-utc_eina_binbuf_append_char.c
-utc_eina_binbuf_append_length.c
-utc_eina_binbuf_free.c
-utc_eina_binbuf_insert_char.c
-utc_eina_binbuf_insert_length.c
-utc_eina_binbuf_length_get.c
-#utc_eina_binbuf_manage_new.c
-utc_eina_binbuf_manage_new_length.c
-utc_eina_binbuf_new.c
-utc_eina_binbuf_remove.c
-utc_eina_binbuf_reset.c
-utc_eina_binbuf_string_free.c
-utc_eina_binbuf_string_get.c
-utc_eina_binbuf_string_steal.c
+utc_eina_binbuf.c
-#utc_eina_binbuf_append_buffer.c
-utc_eina_binbuf_append_char.c
-utc_eina_binbuf_append_length.c
-utc_eina_binbuf_free.c
-utc_eina_binbuf_insert_char.c
-utc_eina_binbuf_insert_length.c
-utc_eina_binbuf_length_get.c
-#utc_eina_binbuf_manage_new.c
-utc_eina_binbuf_manage_new_length.c
-utc_eina_binbuf_new.c
-utc_eina_binbuf_remove.c
-utc_eina_binbuf_reset.c
-utc_eina_binbuf_string_free.c
-utc_eina_binbuf_string_get.c
-utc_eina_binbuf_string_steal.c
+utc_eina_binbuf.c
--- /dev/null
+#include <check.h>
+#include <Eina.h>
+#include <string.h>
+
+/**
+ * @addtogroup eina
+ * @{
+ * @defgroup eina_binbuf
+ *
+ *
+ * @precondition
+ * @step 1 Initialize eina library with eina_init()
+ */
+static void
+setup(void)
+{
+ printf(" ============ Startup ============ \n");
+ eina_init();
+}
+
+static void
+teardown(void)
+{
+ printf(" ============ Cleanup ============ \n");
+ eina_shutdown();
+}
+
+/**
+ * @addtogroup eina_binbuf
+ * @{
+ * @defgroup eina_binbuf_pack_p
+ * @li eina_binbuf_new()
+ * @li eina_binbuf_string_steal()
+ * @li eina_binbuf_append_length()
+ * @li eina_binbuf_string_get()
+ * @li eina_binbuf_length_get()
+ * @li eina_binbuf_free()
+ * @li eina_binbuf_remove()
+ * @li eina_binbuf_manage_new_length()
+ * @li eina_binbuf_manage_new()
+ * @li eina_binbuf_string_free()
+ * @li eina_binbuf_append_buffer()
+ * @li eina_binbuf_reset()
+ * @li eina_binbuf_append_char()
+ * @li eina_binbuf_insert_char()
+ * @li eina_binbuf_insert_length()
+ *
+ * @{
+ * @objective Positive test case 01 checking if the functions works correctly and without errors.
+ *
+ * @procedure
+ * @step 1 Create Eina_Binbuf object by call eina_binbuf_new().
+ * @step 2 Steal the buffer content by call eina_binbuf_string_steal() and check returned pointer.
+ * @step 3 Append string "text" to the buffer and check result.
+ * @step 4 Call eina_binbuf_append_length() and check result.
+ * @step 5 Call eina_binbuf_string_get() and check result.
+ * @step 6 Call eina_binbuf_length_get() and check result.
+ * @step 7 Call eina_binbuf_remove() and check result.
+ * @step 8 Call eina_binbuf_string_get() and check result.
+ * @step 9 Call eina_binbuf_length_get() and check result.
+ * @step 10 Steal the buffer content again and check if it's identical with appended data.
+ * @step 11 Get pointer to content string - it must be non-NULL and point to empty string,
+ * because steal operation reallocates memory of the buffer content.
+ * @step 12 Get length of the buffer - it must be 0 after stealing.
+ * @step 13 Free the buffer and the stolen data by call eina_binbuf_free().
+ * @step 14 Create string and call eina_binbuf_manage_new_length().
+ * @step 15 Call eina_binbuf_string_free() and check result.
+ * @step 16 Call eina_binbuf_manage_new() and check result.
+ * @step 17 Reset buffer by call eina_binbuf_reset().
+ * @step 18 Free buffer and create new.
+ * @step 19 Append lenght to buffer.
+ * @step 20 Create second buffer, call eina_binbuf_append_buffer() and check result.
+ * @step 21 Call eina_binbuf_append_char() and check result.
+ * @step 22 Call eina_binbuf_insert_char() with wrong position and check result -
+ * char must be added in end of buffer.
+ * @step 23 Call eina_binbuf_insert_char() with correct position and check result.
+ * @step 24 Free buffers and create new with string.
+ * @step 25 Call eina_binbuf_insert_length() with wrong position and check result -
+ * size must be changed but not string in buffer.
+ * @step 26 Call eina_binbuf_insert_length() with correct position and check result.
+ *
+ * @passcondition Test passes if returned values are the same as add values.
+ * @}
+ * @}
+ */
+START_TEST(utc_eina_binbuf_pack_p)
+{
+ const char *text1 = "just.text-example";
+ const char *text2 = "just.example";
+ const char *str = NULL;
+ const char* content = NULL;
+ char *ret = NULL;
+ size_t len = 0;
+ Eina_Binbuf *test_buf;
+
+ Eina_Binbuf *buf = eina_binbuf_new();
+ if (!buf)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
+ }
+
+ if (!(ret = (char*)eina_binbuf_string_steal(buf)) || strcmp(ret, ""))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer (no data) steal string is incorrect: %s", __FILE__, __LINE__, ret);
+ }
+
+ if (eina_binbuf_append_length(buf, text1, strlen(text1)) == EINA_FALSE)
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
+ }
+ else if (!(str = (char*)eina_binbuf_string_get(buf)) || strcmp(str, text1))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content (before steal) is incorrect: %s", __FILE__, __LINE__, str);
+ }
+ else if ((len = eina_binbuf_length_get(buf)) != strlen(text1))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (before steal) is incorrect: %u", __FILE__, __LINE__, len);
+ }
+
+ if (eina_binbuf_remove(buf, 50, 64) == EINA_FALSE)
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (len != eina_binbuf_length_get(buf))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (before steal) is incorrect: %u", __FILE__, __LINE__, len);
+ }
+ if (eina_binbuf_remove(buf, 4, 1) == EINA_FALSE)
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (len != eina_binbuf_length_get(buf))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (before steal) is incorrect: %u", __FILE__, __LINE__, len);
+ }
+ if (eina_binbuf_remove(buf, 5, 10) == EINA_FALSE)
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text2))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content after remove is incorrect: %s", __FILE__, __LINE__, ret);
+ }
+ else if ((len = eina_binbuf_length_get(buf)) != strlen(text2))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (before steal) is incorrect: %u", __FILE__, __LINE__, len);
+ }
+
+ ret = (char*)eina_binbuf_string_steal(buf);
+ str = (char*)eina_binbuf_string_get(buf);
+ len = eina_binbuf_length_get(buf);
+ if (!ret || strcmp(ret, text2))
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer stolen string is incorrect: %s", __FILE__, __LINE__, ret);
+ }
+ else if (!str || strcmp(str, ""))
+ {
+ free(ret);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content (after steal) is incorrect: %s", __FILE__, __LINE__, str);
+ }
+ else if (len)
+ {
+ free(ret);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (after steal) is incorrect: %u (must be 0)", __FILE__, __LINE__, len);
+ }
+
+ free(ret);
+ eina_binbuf_free(buf);
+
+ unsigned char* cstr = (unsigned char*)malloc(sizeof(unsigned char) * 7);
+ if (cstr == NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ cstr[0] = 'b';
+ cstr[1] = 'u';
+ cstr[2] = 'f';
+ cstr[3] = 'f';
+ cstr[4] = 'e';
+ cstr[5] = 'r';
+ cstr[6] = '\0';
+
+ buf = eina_binbuf_manage_new_length(cstr, 7);
+ if (buf == NULL)
+ {
+ eina_binbuf_free(buf);
+ free(cstr);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ eina_binbuf_string_free(buf);
+ content = eina_binbuf_string_get(buf);
+ if (content == NULL)
+ {
+ eina_binbuf_free(buf);
+ cstr = NULL;
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (strcmp(content, "") != 0)
+ {
+ eina_binbuf_free(buf);
+ cstr = NULL;
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ cstr = NULL;
+
+ eina_binbuf_free(buf);
+ if (eina_binbuf_string_get(buf) != NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ buf = eina_binbuf_manage_new(text1, strlen(text1), EINA_TRUE);
+ if ((!buf) ||
+ (!eina_binbuf_string_get(buf)) ||
+ (strcmp(eina_binbuf_string_get(buf), text1)) ||
+ (eina_binbuf_length_get(buf) != strlen(text1)))
+ {
+ if (buf != NULL)
+ {
+ eina_binbuf_free(buf);
+ }
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ eina_binbuf_reset(buf);
+ ret = (char*)eina_binbuf_string_steal(buf);
+ if (eina_binbuf_length_get(buf) || (!ret || strcmp(ret, "")))
+ {
+ free(cstr);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ eina_binbuf_free(buf);
+
+ buf = eina_binbuf_new();
+ if (!buf)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (eina_binbuf_append_length(buf, text1, strlen(text1)) == EINA_FALSE)
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
+ }
+ test_buf = eina_binbuf_new();
+ if (!test_buf)
+ {
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ if (!eina_binbuf_append_buffer(test_buf, buf))
+ {
+ free(cstr);
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (memcmp(eina_binbuf_string_get(test_buf), text1, strlen(text1)))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ else if (strlen(text1) != eina_binbuf_length_get(test_buf))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ if (!eina_binbuf_append_char(buf, 't'))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if ((1 + strlen(text1)) != eina_binbuf_length_get(buf) ||
+ (strcmp(eina_binbuf_string_get(buf), "just.text-examplet")))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ if (!eina_binbuf_insert_char(buf, 't', 1000))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if ((2 + strlen(text1)) != eina_binbuf_length_get(buf) ||
+ (strcmp(eina_binbuf_string_get(buf), "just.text-examplett")))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (!eina_binbuf_insert_char(buf, 't', 1))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if ((3 + strlen(text1)) != eina_binbuf_length_get(buf) ||
+ (strcmp(eina_binbuf_string_get(buf), "jtust.text-examplett")))
+ {
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ eina_binbuf_free(test_buf);
+ eina_binbuf_free(buf);
+
+ cstr = (unsigned char*)malloc(sizeof(unsigned char) * 7);
+ if (cstr == NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ cstr[0] = 'b';
+ cstr[1] = 'u';
+ cstr[2] = 'f';
+ cstr[3] = 'f';
+ cstr[4] = 'e';
+ cstr[5] = 'r';
+ cstr[6] = '\0';
+
+ buf = eina_binbuf_manage_new_length(cstr, 7);
+ if (buf == NULL)
+ {
+ free(cstr);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (!eina_binbuf_insert_length(buf, "buf", 4, 1000))
+ {
+ eina_binbuf_string_free(buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (11 != eina_binbuf_length_get(buf) ||
+ (strcmp(eina_binbuf_string_get(buf), "buffer")))
+ {
+ eina_binbuf_string_free(buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (!eina_binbuf_insert_length(buf, "buf", 4, 6))
+ {
+ eina_binbuf_string_free(buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (15 != eina_binbuf_length_get(buf) ||
+ (strcmp(eina_binbuf_string_get(buf), "bufferbuf")))
+ {
+ eina_binbuf_string_free(buf);
+ eina_binbuf_free(buf);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ eina_binbuf_string_free(buf);
+ eina_binbuf_free(buf);
+
+ printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ *@}
+ */
+Suite *
+test_suite(void)
+{
+ Suite *suite = suite_create("utc_eina_binbuf");
+
+ TCase *tcase = tcase_create("TCase");
+ tcase_set_timeout(tcase, 30);
+ tcase_add_checked_fixture(tcase, setup, teardown);
+ tcase_add_test(tcase, utc_eina_binbuf_pack_p);
+ suite_add_tcase(suite, tcase);
+
+ return suite;
+}
+
+int
+main()
+{
+ int number_failed;
+
+ Suite *suite = test_suite();
+ SRunner *srunner = srunner_create(suite);
+ srunner_set_log(srunner, "utc_eina_binbuf.log");
+ srunner_set_xml(srunner, "utc_eina_binbuf.xml");
+ srunner_run_all(srunner, CK_NORMAL);
+ number_failed = srunner_ntests_failed(srunner);
+ srunner_free(srunner);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_append_buffer eina_binbuf_append_buffer()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_append_buffer
- * @{
- * @objective Positive test case 1. Append char to Eina_Binbuf.
- *
- * @n Input Data:
- * @li Valid Eina_Binbuf named buf;
- * @li Valid Eina_Binbuf named test_buf.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 Check on NULL created object
- * @step 3 Append array of char to the buffer.
- * @step 4 Check the return value of the function, content of buffer and size.
- * @step 5 Create new Eina_Binbuf object.
- * @step 6 Append previously created buffer to the new buffer.
- * @step 7 Check the return value of the function, content of buffer and size.
- *
- * @passcondition : API Executes successfully returning EINA_TRUE, buffer content met expectation.
- * @}
- */
-START_TEST(utc_eina_binbuf_append_buffer_p_1)
-{
- Eina_Binbuf *buf, *test_buf;
- 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 */
-
- buf = eina_binbuf_new();
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- eina_binbuf_append_length(buf, cbuf, size);
- if (memcmp(eina_binbuf_string_get(buf), cbuf, size))
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- if (size != eina_binbuf_length_get(buf))
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- test_buf = eina_binbuf_new();
- if (!test_buf)
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- if (!eina_binbuf_append_buffer(test_buf, buf))
- {
- eina_binbuf_free(test_buf);
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- if(memcmp(eina_binbuf_string_get(test_buf), cbuf, size))
- {
- eina_binbuf_free(test_buf);
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- if(size != eina_binbuf_length_get(test_buf))
- {
- eina_binbuf_free(test_buf);
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- eina_binbuf_free(test_buf);
- eina_binbuf_free(buf);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_append_buffer
- * @{
- * @objective Negative test case 1. Call with invalid (NULl) Eina_Binbuf.
- *
- * @n Input Data:
- * @li Invalid (NULL) Eina_Binbuf named buf;
- * @li Char ('s');
- *
- * @procedure
- * @step 1 Try to append buffer to the NULL pointer instead of buffer.
- * @step 2 Check the returned value.
- * @step 3 Try to append NULL to the NULL pointer instead of buffer.
- * @step 4 Check the returned value.
- *
- * @passcondition : API returns EINA_FALSE in all cases, Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_append_buffer_n_1)
-{
-
- Eina_Bool result = EINA_FALSE;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- result = eina_binbuf_append_buffer(NULL, 's');
-
- if (result == EINA_TRUE)
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- result = eina_binbuf_append_buffer(NULL, NULL);
-
- if (result == EINA_TRUE)
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- eina_binbuf_free(buf);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_append_buffer");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_append_buffer_p_1);
- tcase_add_test(tcase, utc_eina_binbuf_append_buffer_n_1);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_append_buffer.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_append_buffer.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_append_char eina_binbuf_append_char()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_append_char
- * @{
- * @objective Positive test case 1. Append char to Eina_Binbuf.
- *
- * @n Input Data:
- * @li Valid Eina_Binbuf named buf;
- * @li Char ('t').
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 Append char to the buffer.
- * @step 3 Check the return value of the function and content of buffer.
- *
- * @passcondition : API Executes successfully returning EINA_TRUE, buffer content met expectation.
- * @}
- */
-START_TEST(utc_eina_binbuf_append_char_p_1)
-{
-
- Eina_Binbuf* buf = NULL;
- Eina_Bool result = EINA_FALSE;
- const char* expected_str = "t";
- const char* content = NULL;
-
- buf = eina_binbuf_new();
- result = eina_binbuf_append_char(buf, 't');
-
- if (result != EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- content = eina_binbuf_string_get(buf);
-
- if (content == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
- if (strcmp(content, expected_str) != 0)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_append_char
- * @{
- * @objective Negative test case 1. Call with invalid (NULl) Eina_Binbuf.
- *
- * @n Input Data:
- * @li Invalid (NULL) Eina_Binbuf named buf;
- * @li Char ('s');
- *
- * @procedure
- * @step 1 Try to append char to the NULL pointer instead of buffer.
- * @step 2 Check the returned value.
- *
- * @passcondition : API returns EINA_FALSE, Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_append_char_n_1)
-{
-
- Eina_Bool result = EINA_FALSE;
-
- result = eina_binbuf_append_char(NULL, 's');
-
- if (result == EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_append_char");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_append_char_p_1);
- tcase_add_test(tcase, utc_eina_binbuf_append_char_n_1);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_append_char.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_append_char.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include <string.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_append_length eina_binbuf_append_length()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_append_length
- * @{
- * @objective Positive test case checks if function appends a string with exactly length to given buffer properly.
- * @n Input Data:
- * @li pointer to Eina_Binbuf;
- * @li "text" as string to append;
- * @li strlen("text") as data length.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Check length and content of the buffer to ensure that string was added correctly
- *
- * @passcondition Function returns EINA_TRUE, got and set strings are identical, got length
- * and length of the appended string are the same.
- * @}
- */
-START_TEST(utc_eina_binbuf_append_length_p)
-{
- const char *text = "text";
- size_t len1 = strlen(text);
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, len1) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Function has returned EINA_FALSE..", __FILE__, __LINE__);
- }
- else
- {
- const char *ret = (char*)eina_binbuf_string_get(buf);
- size_t len2 = eina_binbuf_length_get(buf);
-
- if (!ret || strcmp(ret, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else if (len2 != len1)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length is incorrect: %u", __FILE__, __LINE__, len2);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_append_length
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * and returns EINA_FALSE if it is called with NULL instead of some arguments.
- * @n Input Data:
- * @li pointer to Eina_Binbuf;
- * @li "text" as string to append;
- * @li strlen("text") as data length.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Call function 2 times and pass (in turn) NULL instead of buffer and string to append
- *
- * @passcondition Function doesn't cause segmentation fault and returns EINA_FALSE.
- * @}
- */
-START_TEST(utc_eina_binbuf_append_length_n1)
-{
- const char *text = "text";
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- return;
- }
-
- CREATE_CHECKED_ARGS_ARRAY(1, 1, 0);
- UNITEST_FUNC_NEG_CA_RET(EINA_FALSE, eina_binbuf_append_length, buf, text, strlen(text));
-
- if (result_of_testing == TEST_FAIL)
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- else
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_append_length
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault
- * and returns EINA_FALSE if it is called with negative length of the some string.
- * @n Input Data:
- * @li pointer to Eina_Binbuf;
- * @li "text" as string to append;
- * @li -100 negative value as data length.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Call function with wrong input data
- *
- * @passcondition Function doesn't cause segmentation fault and returns EINA_FALSE.
- * @}
- */
-#ifdef NOT_APPROVED_FOR_BUILD
-START_TEST(utc_eina_binbuf_append_length_n2)
-{
- Eina_Bool result;
- const char *text = "text";
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- return;
- }
-
- result = eina_binbuf_append_length(buf, text, -100);
-
- if (result)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-#endif
-
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_append_length");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_append_length_p);
- tcase_add_test(tcase, utc_eina_binbuf_append_length_n1);
-#ifdef NOT_APPROVED_FOR_BUILD
- tcase_add_test(tcase, utc_eina_binbuf_append_length_n2);
-#endif
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_append_length.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_append_length.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_free eina_binbuf_free()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_free
- * @{
- * @objective Positive test case 1 checks if function executes successfully.
- * @n Input Data: pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object with eina_binbuf_new()
- * @step 2 Free the buffer
- *
- * @passcondition Function executes successfully.
- * @}
- */
-START_TEST(utc_eina_binbuf_free_p)
-{
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- return;
- }
- eina_binbuf_free(buf);
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_free
- * @{
- * @objective Positive test case 2 checks if function frees given buffer successfully.
- * @n Input Data: pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Allocate memory
- * @step 2 Create Eina_Binbuf object with eina_binbuf_manage_new_length() from allocated memory
- * @step 3 Free the buffer
- * @step 4 Check if buffer content is NULL
- *
- * @passcondition Function frees buffer successfully, buffer content is NULL.
- * @}
- */
-START_TEST(utc_eina_binbuf_free_p2)
-{
- unsigned char *my_buffer = malloc(sizeof(unsigned char) * 512);
-
- if (!my_buffer)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memory is not allocated..", __FILE__, __LINE__);
- return;
- }
- Eina_Binbuf *buf = eina_binbuf_manage_new_length(my_buffer, 512);
- /*TODO Write test-case for function eina_binbuf_manage_new_length(unsigned char *str, size_t length)*/
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- return;
- }
- eina_binbuf_free(buf);
-
- if (eina_binbuf_string_get(buf))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_free
- * @{
- * @objective Negative test case checks if function doesn't cause segmentation fault
- * if it is called with NULL instead of pointer to Eina_Binbuf.
- * @n Input Data: NULL as pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Call function and pass NULL instead of its argument
- *
- * @passcondition Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_free_n)
-{
-
- UNITEST_FUNC_NEG(eina_binbuf_free, NULL);
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_free");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_free_p);
- tcase_add_test(tcase, utc_eina_binbuf_free_p2);
- tcase_add_test(tcase, utc_eina_binbuf_free_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_free.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_free.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_insert_char eina_binbuf_insert_char()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_insert_char
- * @{
- * @objective Positive test case 1. Insert char to Eina_Binbuf.
- *
- * @n Input Data:
- * @li Valid Eina_Binbuf named buf;
- * @li Char ('t');
- * @li Position in the buffer
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 Insert char to the buffer.
- * @step 3 Check the return value of the function and content of buffer.
- *
- * @passcondition : API Executes successfully returning EINA_TRUE, buffer content met expectation.
- * @}
- */
-START_TEST(utc_eina_binbuf_insert_char_p_1)
-{
-
- Eina_Binbuf* buf = NULL;
- Eina_Bool result = EINA_FALSE;
- const char* expected_str = "buffert";
- const char* content = NULL;
-
- unsigned char* str = (unsigned char*)malloc(sizeof(unsigned char) * 7);
- if (str == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
-
- str[0] = 'b';
- str[1] = 'u';
- str[2] = 'f';
- str[3] = 'f';
- str[4] = 'e';
- str[5] = 'r';
- str[6] = '\0';
-
- buf = eina_binbuf_manage_new_length(str, 7);
-
- if (buf == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- result = eina_binbuf_insert_char(buf, 't', 6);
-
- if (result != EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- content = eina_binbuf_string_get(buf);
-
- if (content == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
- if (strcmp(content, expected_str) != 0)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_insert_char
- * @{
- * @objective Negative test case 1. Call with invalid (NULl) Eina_Binbuf.
- *
- * @n Input Data:
- * @li Invalid (NULL) Eina_Binbuf named buf;
- * @li Char ('s');
- * @li Position in the buffer
- *
- * @procedure
- * @step 1 Try to append char to the NULL pointer instead of buffer.
- * @step 2 Check the returned value.
- *
- * @passcondition : API returns EINA_FALSE, Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_insert_char_n_1)
-{
-
- Eina_Bool result = EINA_FALSE;
-
- result = eina_binbuf_insert_char(NULL, 's' , 0);
-
- if (result == EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_insert_char");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_insert_char_p_1);
- tcase_add_test(tcase, utc_eina_binbuf_insert_char_n_1);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_insert_char.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_insert_char.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_insert_length eina_binbuf_insert_length()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_insert_length
- * @{
- * @objective Positive test case 1. Insert char to Eina_Binbuf.
- *
- * @n Input Data:
- * @li Valid Eina_Binbuf named buf;
- * @li String "buf";
- * @li Length of the string
- * @li Position in the buffer
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 Insert string to the buffer.
- * @step 3 Check the return value of the function and content of buffer.
- *
- * @passcondition : API Executes successfully returning EINA_TRUE, buffer content met expectation.
- * @}
- */
-START_TEST(utc_eina_binbuf_insert_length_p_1)
-{
-
- Eina_Binbuf* buf = NULL;
- Eina_Bool result = EINA_FALSE;
- const char* expected_str = "bufferbuf";
- const char* content = NULL;
-
- unsigned char* str = (unsigned char*)malloc(sizeof(unsigned char) * 7);
- if (str == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
-
- str[0] = 'b';
- str[1] = 'u';
- str[2] = 'f';
- str[3] = 'f';
- str[4] = 'e';
- str[5] = 'r';
- str[6] = '\0';
-
- buf = eina_binbuf_manage_new_length(str, 7);
-
- if (buf == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- result = eina_binbuf_insert_length(buf, "buf", 4, 6);
-
- if (result != EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- content = eina_binbuf_string_get(buf);
-
- if (content == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
- if (strcmp(content, expected_str) != 0)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_insert_length
- * @{
- * @objective Negative test case 1. Call with invalid (NULl) Eina_Binbuf.
- *
- * @n Input Data:
- * @li Invalid (NULL) Eina_Binbuf named buf;
- * @li String "buf";
- * @li Length of the string
- * @li Position in the buffer
- *
- * @procedure
- * @step 1 Try to insert string to the NULL pointer instead of buffer.
- * @step 2 Check the returned value.
- *
- * @passcondition : API returns EINA_FALSE, Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_insert_length_n_1)
-{
-
- Eina_Bool result = EINA_FALSE;
-
- result = eina_binbuf_insert_length(NULL, "buf" , 4, 1);
-
- if (result == EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_insert_length");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_insert_length_p_1);
- tcase_add_test(tcase, utc_eina_binbuf_insert_length_n_1);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_insert_length.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_insert_length.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_length_get eina_binbuf_length_get()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_length_get
- * @{
- * @objective Positive test case checks if function returns length of the string buffer content.
- * @n Input Data: pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Get length of the buffer and compare it with length of the string
- * @step 4 Reset the buffer
- * @step 5 Get length of the buffer and check if it is 0
- *
- * @passcondition Function returns length of the buffer properly: strlen("text") for first and 0 for second call.
- * @}
- */
-START_TEST(utc_eina_binbuf_length_get_p)
-{
- const char *text = "text";
- size_t len1 = strlen(text);
- size_t len2 = 0;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, len1) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if ((len2 = eina_binbuf_length_get(buf)) != len1)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length is incorrect: %u", __FILE__, __LINE__, len2);
- }
- else
- {
- eina_binbuf_reset(buf);
- len2 = eina_binbuf_length_get(buf);
-
- if (len2)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length after reset is incorrect: %u", __FILE__, __LINE__, len2);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_length_get
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * and returns 0 if it is called with NULL instead of pointer to Eina_Binbuf.
- * @n Input Data: NULL as pointer to buffer.
- *
- * @procedure
- * @step 1 Call function and pass NULL instead of its argument
- *
- * @passcondition Function doesn't cause segmentation fault and returns 0.
- * @}
- */
-START_TEST(utc_eina_binbuf_length_get_n)
-{
-
- if (UNITEST_FUNC_NEG_RET(0, eina_binbuf_length_get, NULL) == TEST_FAIL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_length_get
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault
- * and returns 0 if it is called with freed buffer.
- * @n Input Data: pointer to Eina_Binbuf that was freed.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Free the buffer
- * @step 4 Get length of the buffer and check if it is 0
- *
- * @passcondition Function doesn't cause segmentation fault and returns 0.
- * @}
- */
-START_TEST(utc_eina_binbuf_length_get_n2)
-{
- const char *text = "text";
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else
- {
- eina_binbuf_free(buf);
-
- if (eina_binbuf_length_get(buf))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length after free is incorrect..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_length_get");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_length_get_p);
- tcase_add_test(tcase, utc_eina_binbuf_length_get_n);
- tcase_add_test(tcase, utc_eina_binbuf_length_get_n2);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_length_get.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_length_get.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-#define INPUT_DATA "inout_data"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_manage_new eina_binbuf_manage_new()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_manage_new
- * @{
- * @objective Positive test case checks if function creates a new string buffer using the passed string
- *
- * @n Input Data:
- * @li INPUT_DATA - the string to start from;
- * @li strlen(INPUT_DATA) - the length of the string;
- * @li EINA_FALSE/EINA_TRUE - the passed string will not be touched if set to EINA_TRUE
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 check new Eina_Binbuf object with input parameters.
- *
- * @passcondition : Test passed if Eina_Binbuf object string is equal INPUT_DATA,
- * length of Eina_Binbuf object is equal strlen(INPUT_DATA)
- * and there is no segmentation fail.
- * @}
- */
-START_TEST(utc_eina_binbuf_manage_new_p)
-{
- Eina_Binbuf *buf = eina_binbuf_manage_new(INPUT_DATA, strlen(INPUT_DATA), EINA_TRUE);
-
- if ((!buf) ||
- (!eina_binbuf_string_get(buf)) ||
- (strcmp(eina_binbuf_string_get(buf), INPUT_DATA)) ||
- (eina_binbuf_length_get(buf) != strlen(INPUT_DATA)))
- {
- if (buf)
- {
- eina_binbuf_free(buf);
- }
-
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
-
- eina_binbuf_free(buf);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_manage_new");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_manage_new_p);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_manage_new.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_manage_new.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_manage_new_length eina_binbuf_manage_new_length()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_manage_new_length
- * @{
- * @objective Positive test case 1. Create Eina_Binbuf.
- *
- * @n Input Data:
- * @li pointer to array of unsigned chars;
- * @li Length of the string
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 Check the return value of the function and content of buffer.
- *
- * @passcondition : API Executes successfully returning EINA_TRUE, buffer content met expectation.
- * @}
- */
-START_TEST(utc_eina_binbuf_manage_new_length_p_1)
-{
-
- Eina_Binbuf* buf = NULL;
- const char* expected_str = "buffer";
- const char* content = NULL;
-
- unsigned char* str = (unsigned char*)malloc(sizeof(unsigned char) * 7);
- if (str == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
-
- str[0] = 'b';
- str[1] = 'u';
- str[2] = 'f';
- str[3] = 'f';
- str[4] = 'e';
- str[5] = 'r';
- str[6] = '\0';
-
- buf = eina_binbuf_manage_new_length(str, 7);
-
- if (buf == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- content = eina_binbuf_string_get(buf);
-
- if (content == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- if (strcmp(content, expected_str) != 0)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_manage_new_length
- * @{
- * @objective Negative test case 1. Call with invalid (NULl) Eina_Binbuf.
- *
- * @n Input Data:
- * @li Invalid (NULL) pointer to array of unsigned chars;
- * @li Length of the string
- *
- * @procedure
- * @step 1 Try to create Eina_Binbuf object with NULL pointer to array of unsigned chars.
- * @step 2 Check the returned value.
- *
- * @passcondition : API returns EINA_FALSE, Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_manage_new_length_n_1)
-{
-
- Eina_Bool result = EINA_FALSE;
-
- result = eina_binbuf_manage_new_length(NULL, 4);
-
- if (result == EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_manage_new_length");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_manage_new_length_p_1);
- tcase_add_test(tcase, utc_eina_binbuf_manage_new_length_n_1);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_manage_new_length.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_manage_new_length.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_new eina_binbuf_new()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_new
- * @{
- * @objective Positive test case checks if function creates string buffer successfully.
- * @n Input Data: function has no arguments
- *
- * @procedure
- * @step 1 Create new Eina_Binbuf object
- * @step 2 Check if returned pointer is not NULL
- *
- * @passcondition Function executes successfully and returns non-NULL pointer to created Eina_Binbuf.
- * @}
- */
-START_TEST(utc_eina_binbuf_new_p)
-{
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- eina_binbuf_free(buf);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_new");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_new_p);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_new.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_new.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include <string.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_remove eina_binbuf_remove()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_remove
- * @{
- * @objective Positive test case checks if function removes a slice from given buffer properly.
- * @n Input Data:
- * @li pointer to Eina_Binbuf;
- * @li 5 as initial (inclusive) slice position to start removing;
- * @li 10 as final (non-inclusive) slice position to finish removing.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "just.text-example" to it and check result
- * @step 3 Check length and content of the buffer to ensure that data was actually added
- * @step 4 Remove 5 chars from the buffer - "text-"
- * @step 5 Get buffer content and check if it equals "just.example"
- * @step 6 Get buffer length and check if it matches with length of "just.example"
- *
- * @passcondition Function removes slice from buffer properly. Buffer content "just.text-example"
- * after removing from 5 to 10 positions is "just.example" and has proper length.
- * @}
- */
-START_TEST(utc_eina_binbuf_remove_p)
-{
- const char *text1 = "just.text-example";
- const char *text2 = "just.example";
- const char *ret = NULL;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text1, strlen(text1)) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text1))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content before remove is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else if (eina_binbuf_length_get(buf) != strlen(text1))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length before remove is incorrect..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_remove(buf, 5, 10) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Function has returned EINA_FALSE..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text2))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content after remove is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else if (eina_binbuf_length_get(buf) != strlen(text2))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length after remove is incorrect..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_remove
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * and returns EINA_FALSE if it is called with NULL instead of pointer to Eina_Binbuf.
- * @n Input Data:
- * @li NULL as pointer to Eina_Binbuf;
- * @li 5 as initial slice position to start removing;
- * @li 10 as final slice position to finish removing.
- *
- * @procedure
- * @step 1 Call function once and pass NULL instead of buffer
- *
- * @passcondition Function doesn't cause segmentation fault and returns EINA_FALSE.
- * @}
- */
-START_TEST(utc_eina_binbuf_remove_n)
-{
-
- CREATE_CHECKED_ARGS_ARRAY(1, 0, 0);
- UNITEST_FUNC_NEG_CA_RET(EINA_FALSE, eina_binbuf_remove, NULL, 5, 10);
-
- if (result_of_testing == TEST_FAIL)
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- else
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_remove
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault, returns EINA_TRUE
- * but doesn't actually modifies buffer if it is called with incorrect start and finish positions.
- * @n Input Data:
- * @li pointer to Eina_Binbuf;
- * @li 3/10 as initial slice position to start removing for first/second call;
- * @li 1/12 as final slice position to finish removing for first/second call.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Get buffer content string and check if it's identical with appended one
- * @step 4 Try remove slice from 3 to 1 position (incorrect arguments - back order, start greater than end)
- * @step 5 Try remove slice from 10 to 12 position (incorrect arguments - positions are greater than buffer length)
- * @step 6 Get buffer content and check that it wasn't modified
- *
- * @passcondition Function doesn't cause segmentation fault and doesn't change content of the buffer.
- * @}
- */
-START_TEST(utc_eina_binbuf_remove_n2)
-{
- const char *text = "text";
- const char *ret = NULL;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content before remove is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else if (eina_binbuf_remove(buf, 3, 1) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Function has returned EINA_FALSE for (3,1) positions..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_remove(buf, 10, 12) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Function has returned EINA_FALSE for (10,12) positions..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content after remove is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_remove");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_remove_p);
- tcase_add_test(tcase, utc_eina_binbuf_remove_n);
- tcase_add_test(tcase, utc_eina_binbuf_remove_n2);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_remove.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_remove.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include <string.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_reset eina_binbuf_reset()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_reset
- * @{
- * @objective Positive test case checks if function resets given string buffer properly.
- * @n Input Data: pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Check length and content of the buffer to ensure that data was added
- * @step 4 Reset the buffer
- * @step 5 Get string and stolen string from the buffer and check if they are empty
- * @step 6 Get length of the buffer and check if it equals 0
- *
- * @passcondition Got string and stolen string are empty, length equals 0.
- * @}
- */
-START_TEST(utc_eina_binbuf_reset_p)
-{
- const char *text = "text";
- size_t len = strlen(text);
- const char *ret = NULL;
- char *steal = NULL;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, len) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_length_get(buf) != len)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length is incorrect..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content is incorrect..", __FILE__, __LINE__);
- }
- else
- {
- eina_binbuf_reset(buf);
-
- ret = (char*)eina_binbuf_string_get(buf);
- steal = (char*)eina_binbuf_string_steal(buf);
-
- if (eina_binbuf_length_get(buf) || (!ret || strcmp(ret, "")) || (!steal || strcmp(steal, "")))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- free(steal);
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_reset
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * if it is called with NULL instead of pointer to Eina_Binbuf.
- * @n Input Data: NULL as pointer to string buffer.
- *
- * @procedure
- * @step 1 Call function and pass NULL instead of its argument
- *
- * @passcondition Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_reset_n1)
-{
-
- UNITEST_FUNC_NEG(eina_binbuf_reset, NULL);
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_reset
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault
- * if it is called with freed buffer.
- * @n Input Data: pointer to Eina_Binbuf that was freed.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Free the buffer
- * @step 4 Reset the buffer
- * @step 5 Get length of the buffer and check if it is 0
- *
- * @passcondition Function doesn't cause segmentation fault, buffer length equals 0.
- * @}
- */
-START_TEST(utc_eina_binbuf_reset_n2)
-{
- size_t len;
- const char *text = "text";
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else
- {
- eina_binbuf_free(buf);
- eina_binbuf_reset(buf);
- len = eina_binbuf_length_get(buf);
-
- if (len)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length after reset is incorrect: %u", __FILE__, __LINE__, len);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
-
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_reset");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_reset_p);
- tcase_add_test(tcase, utc_eina_binbuf_reset_n1);
- tcase_add_test(tcase, utc_eina_binbuf_reset_n2);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_reset.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_reset.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_string_free eina_binbuf_string_free()
- *
- *
- * @precondition
- * @step 1 eina initialized with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_string_free
- * @{
- * @objective Positive test case 1. Free string Eina_Binbuf, but not the buffer.
- *
- * @n Input Data:
- * @li Valid Eina_Binbuf named buf;
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object.
- * @step 2 Free string of Eina_Binbuf
- * @step 3 Check the content of buffer.
- *
- * @passcondition : API Executes successfully, buffer content met expectation.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_free_p_1)
-{
-
- Eina_Binbuf* buf = NULL;
- const char* expected_str = "";
- const char* content = NULL;
-
- unsigned char* str = (unsigned char*)malloc(sizeof(unsigned char) * 7);
- if (str == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
-
- str[0] = 'b';
- str[1] = 'u';
- str[2] = 'f';
- str[3] = 'f';
- str[4] = 'e';
- str[5] = 'r';
- str[6] = '\0';
-
- buf = eina_binbuf_manage_new_length(str, 7);
-
- if (buf == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_binbuf_free(buf);
- return;
- }
-
- eina_binbuf_string_free(buf);
-
- content = eina_binbuf_string_get(buf);
-
- if (content == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- if (strcmp(content, expected_str) != 0)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- eina_strbuf_free(buf);
- return;
- }
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_string_free
- * @{
- * @objective Negative test case 1. Call with invalid (NULl) Eina_Binbuf.
- *
- * @n Input Data:
- * @li Invalid (NULL) pointer to Eina_Binbuf;
- *
- * @procedure
- * @step 1 Try to call function with NULL pointer to Eina_Binbuf.
- *
- * @passcondition : Function doesn't cause segmentation fault.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_free_n_1)
-{
-
- eina_binbuf_string_free(NULL);
-
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_string_free");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_string_free_p_1);
- tcase_add_test(tcase, utc_eina_binbuf_string_free_n_1);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_string_free.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_string_free.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include <string.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_string_get eina_binbuf_string_get()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_string_get
- * @{
- * @objective Positive test case checks if function returns pointer to content of the given string buffer properly.
- * @n Input Data: pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Get pointer to content - retrieved pointer must be non-NULL and point to empty string
- * @step 3 Append string "text" to it and check result
- * @step 4 Get pointer to content and compare retrieved and appended strings
- *
- * @passcondition
- * @li first call (before adding data) - function returns non-NULL pointer that points to empty string;
- * @li second call (after adding data to the buffer) - retrieved data is identical with appended
- * to the buffer on step 3.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_get_p)
-{
- const char *text = "text";
- char *ret = NULL;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, ""))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer (no data) content is not empty: %s", __FILE__, __LINE__, ret);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer (with data) content is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_string_get
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * and returns NULL if it is called with NULL instead of pointer to Eina_Binbuf.
- * @n Input Data: NULL as pointer to buffer.
- *
- * @procedure
- * @step 1 Call function and pass NULL instead of its argument
- *
- * @passcondition Function doesn't cause segmentation fault and returns NULL.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_get_n)
-{
-
- if (UNITEST_FUNC_NEG_RET(NULL, eina_binbuf_string_get, NULL) == TEST_FAIL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_string_get
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault
- * if it is called with freed buffer.
- * @n Input Data: pointer to Eina_Binbuf that was freed.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Call tested function and compare got and appended strings
- * @step 4 Free the buffer
- * @step 5 Call tested function to get content
- * @step 6 Check if retrieved pointer is NULL
- *
- * @passcondition Function doesn't cause segmentation fault and returns NULL for released buffer.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_get_n2)
-{
- const char *text = "text";
- const char *ret = NULL;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text))
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer (with data) content is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else
- {
- eina_binbuf_free(buf);
- ret = (char*)eina_binbuf_string_get(buf);
-
- if (ret)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer after free is not empty: %s", __FILE__, __LINE__, ret);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_string_get");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_string_get_p);
- tcase_add_test(tcase, utc_eina_binbuf_string_get_n);
- tcase_add_test(tcase, utc_eina_binbuf_string_get_n2);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_string_get.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_string_get.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include <string.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eina_binbuf
- * @{
- * @defgroup eina_binbuf_string_steal eina_binbuf_string_steal()
- *
- *
- * @precondition
- * @step 1 Initialize eina library with eina_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eina_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eina_shutdown();
-}
-
-/**
- * @addtogroup eina_binbuf_string_steal
- * @{
- * @objective Positive test case checks if function steals and returns the buffer content properly.
- * @n Input Data: pointer to Eina_Binbuf.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Steal the buffer content and check if returned pointer is non-NULL and pointed string is empty ("")
- * @step 3 Append string "text" to the buffer and check result
- * @step 4 Free memory with stolen data got on step 2
- * @step 5 Steal the buffer content again and check if it's identical with appended data
- * @step 6 Get pointer to content string - it must be non-NULL and point to empty string,
- * because steal operation reallocates memory of the buffer content
- * @step 7 Get length of the buffer - it must be 0 after stealing
- * @step 8 Free the buffer and the stolen data
- *
- * @passcondition
- * @li first call (before adding data to the buffer) - function returns non-NULL pointer that points to empty string;
- * @li second call (after adding data) - stolen data is identical with appended one, content string
- * is empty (but not NULL) and buffer length equals 0.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_steal_p)
-{
- const char *text = "text";
- const char *str = NULL;
- char *ret = NULL;
- size_t len = 0;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_steal(buf)) || strcmp(ret, ""))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer (no data) steal string is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (!(str = (char*)eina_binbuf_string_get(buf)) || strcmp(str, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content (before steal) is incorrect: %s", __FILE__, __LINE__, str);
- }
- else if ((len = eina_binbuf_length_get(buf)) != strlen(text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (before steal) is incorrect: %u", __FILE__, __LINE__, len);
- }
- else
- {
- free(ret);
- ret = (char*)eina_binbuf_string_steal(buf);
- str = (char*)eina_binbuf_string_get(buf);
- len = eina_binbuf_length_get(buf);
-
- if (!ret || strcmp(ret, text))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer stolen string is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else if (!str || strcmp(str, ""))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer content (after steal) is incorrect: %s", __FILE__, __LINE__, str);
- }
- else if (len)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer length (after steal) is incorrect: %u (must be 0)", __FILE__, __LINE__, len);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
- free(ret);
- eina_binbuf_free(buf);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_string_steal
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * and returns NULL if it is called with NULL instead of pointer to Eina_Binbuf.
- * @n Input Data: NULL as pointer to buffer.
- *
- * @procedure
- * @step 1 Call function and pass NULL instead of its argument
- *
- * @passcondition Function doesn't cause segmentation fault and returns NULL.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_steal_n)
-{
-
- if (UNITEST_FUNC_NEG_RET(NULL, eina_binbuf_string_steal, NULL) == TEST_FAIL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eina_binbuf_string_steal
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault
- * if it is called with freed buffer.
- * @n Input Data: pointer to Eina_Binbuf that was freed.
- *
- * @procedure
- * @step 1 Create Eina_Binbuf object
- * @step 2 Append string "text" to it and check result
- * @step 3 Get pointer to content string and compare got and appended strings
- * @step 4 Free the buffer
- * @step 5 Call tested function to get stolen string
- * @step 6 Check if retrieved pointer is NULL
- *
- * @passcondition Function doesn't cause segmentation fault and returns NULL for released buffer.
- * @}
- */
-START_TEST(utc_eina_binbuf_string_steal_n2)
-{
- const char *text = "text";
- const char *ret = NULL;
- int result = TEST_FAIL;
- Eina_Binbuf *buf = eina_binbuf_new();
-
- if (!buf)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Eina_Binbuf is not created..", __FILE__, __LINE__);
- }
- else if (eina_binbuf_append_length(buf, text, strlen(text)) == EINA_FALSE)
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Data is not appended to buffer..", __FILE__, __LINE__);
- }
- else if (!(ret = (char*)eina_binbuf_string_get(buf)) || strcmp(ret, text))
- {
- eina_binbuf_free(buf);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer (with data) content is incorrect: %s", __FILE__, __LINE__, ret);
- }
- else
- {
- eina_binbuf_free(buf);
- ret = (char*)eina_binbuf_string_steal(buf);
-
- if (ret)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Buffer after free is not empty: %s", __FILE__, __LINE__, ret);
- free(ret);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- result = TEST_PASS;
- }
- }
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eina_binbuf_string_steal");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eina_binbuf_string_steal_p);
- tcase_add_test(tcase, utc_eina_binbuf_string_steal_n);
- tcase_add_test(tcase, utc_eina_binbuf_string_steal_n2);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eina_binbuf_string_steal.log");
- srunner_set_xml(srunner, "utc_eina_binbuf_string_steal.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}