static int callbackFunctionCount = 0;
-static Eina_Bool callback(const void *container, void *data, void *fdata)
+static int callback(const void *data1, const void *data2)
{
- return EINA_TRUE;
+ callbackFunctionCount = 1;
+ return 1;
}
/**
* @objective Positive test case 01: provide a safe way to iterate over an array
* @n Input data:
* @ li arr The array to iterate over
- * @ li callback The callback to call for each item
- * @ li data The user data to pass to the callback
+ * @ li data The user data to pass to the array
+ * @ li callback The callback to compare each item
*
* @procedure
* @step 1 Create a new array
* @step 2 Push some data to the array
- * @step 3 Provide a safe way to iterate over an array
+ * @step 3 Insert new data to array and check if compare function was called
*
- * @passcondition: Successfully iterate all items of the array
+ * @passcondition: eina_inarray_insert should return position (not -1) and compare
+ * function should be called
* @}
*/
START_TEST(utc_eina_inarray_insert_p_1)
unsigned int i;
Eina_Inarray* arr = eina_inarray_new(MEMBER_SIZE, INARRAY_SIZE);
- if ( arr == NULL )
+ if (arr == NULL)
{
ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
}
for (i = 0; i < INARRAY_SIZE; ++i)
- eina_inarray_push(arr, strs[i]);
+ eina_inarray_push(arr, strs[i]);
- if ( eina_inarray_insert(arr, callback, NULL) )
+ if (eina_inarray_insert(arr, "eleven", callback) == -1)
{
eina_inarray_free(arr);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- return;
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ if (callbackFunctionCount == 0)
+ {
+ eina_inarray_free(arr);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
}
eina_inarray_free(arr);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
}
END_TEST
static int callbackFunctionCount = 0;
-static Eina_Bool callback(const void *container, void *data, void *fdata)
+static int callback(const void *data1, const void *data2)
{
- return EINA_TRUE;
+ callbackFunctionCount = 1;
+ return 1;
}
/**
* @objective Positive test case 01: provide a safe way to iterate over an array
* @n Input data:
* @ li arr The array to iterate over
- * @ li callback The callback to call for each item
- * @ li data The user data to pass to the callback
+ * @ li data The user data to pass to the array
+ * @ li callback The callback to compare each item
*
* @procedure
* @step 1 Create a new array
* @step 2 Push some data to the array
- * @step 3 Provide a safe way to iterate over an array
+ * @step 3 Insert new data to sorted array and check if compare function was called
*
- * @passcondition: Successfully iterate all items of the array
+ * @passcondition: eina_inarray_insert_sorted should return position (not -1) and compare
+ * function should be called
* @}
*/
START_TEST(utc_eina_inarray_insert_sorted_p_1)
unsigned int i;
Eina_Inarray* arr = eina_inarray_new(MEMBER_SIZE, INARRAY_SIZE);
- if ( arr == NULL )
+ if (arr == NULL)
{
ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- return;
}
for (i = 0; i < INARRAY_SIZE; ++i)
- eina_inarray_push(arr, strs[i]);
+ eina_inarray_push(arr, strs[i]);
- if ( eina_inarray_insert_sorted(arr, callback, NULL) )
+ if (eina_inarray_insert_sorted(arr, "ddd", callback) == -1)
{
eina_inarray_free(arr);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- return;
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ if (callbackFunctionCount == 0)
+ {
+ eina_inarray_free(arr);
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
}
eina_inarray_free(arr);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
}
END_TEST