/**
* @brief Create queue.
*/
-bool
+int
nns_edge_queue_create (nns_edge_queue_h * handle)
{
nns_edge_queue_s *q;
if (!handle) {
nns_edge_loge ("[Queue] Invalid param, handle is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
q = calloc (1, sizeof (nns_edge_queue_s));
if (!q) {
nns_edge_loge ("[Queue] Failed to allocate new memory.");
- return false;
+ return NNS_EDGE_ERROR_OUT_OF_MEMORY;
}
nns_edge_lock_init (q);
q->leaky = NNS_EDGE_QUEUE_LEAK_NEW;
*handle = q;
- return true;
+ return NNS_EDGE_ERROR_NONE;
}
/**
* @brief Destroy queue.
*/
-bool
+int
nns_edge_queue_destroy (nns_edge_queue_h handle)
{
nns_edge_queue_s *q = (nns_edge_queue_s *) handle;
if (!q) {
nns_edge_loge ("[Queue] Invalid param, queue is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
/* Stop waiting and clear all data. */
nns_edge_lock_destroy (q);
SAFE_FREE (q);
- return true;
+ return NNS_EDGE_ERROR_NONE;
}
/**
/**
* @brief Set the max length of the queue.
*/
-bool
+int
nns_edge_queue_set_limit (nns_edge_queue_h handle, unsigned int limit,
nns_edge_queue_leak_e leaky)
{
if (!q) {
nns_edge_loge ("[Queue] Invalid param, queue is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
nns_edge_lock (q);
q->leaky = leaky;
nns_edge_unlock (q);
- return true;
+ return NNS_EDGE_ERROR_NONE;
}
/**
* @brief Add new data into queue.
*/
-bool
+int
nns_edge_queue_push (nns_edge_queue_h handle, void *data, nns_size_t size,
nns_edge_data_destroy_cb destroy)
{
+ int ret = NNS_EDGE_ERROR_NONE;
nns_edge_queue_s *q = (nns_edge_queue_s *) handle;
nns_edge_queue_data_s *qdata;
- bool pushed = false;
if (!q) {
nns_edge_loge ("[Queue] Invalid param, queue is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
if (!data) {
nns_edge_loge ("[Queue] Invalid param, data is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
if (size == 0U) {
nns_edge_loge ("[Queue] Invalid param, size should be larger than zero.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
nns_edge_lock (q);
} else {
nns_edge_logw ("[Queue] Cannot push new data, max data in queue is %u.",
q->max_data);
+ ret = NNS_EDGE_ERROR_IO;
goto done;
}
}
qdata = calloc (1, sizeof (nns_edge_queue_data_s));
if (!qdata) {
nns_edge_loge ("[Queue] Failed to allocate new memory for data.");
+ ret = NNS_EDGE_ERROR_OUT_OF_MEMORY;
goto done;
}
q->tail->next = qdata;
q->tail = qdata;
q->length++;
- pushed = true;
done:
nns_edge_cond_signal (q);
nns_edge_unlock (q);
- return pushed;
+ return ret;
}
/**
* @brief Remove and return the first data in queue.
*/
-bool
+int
nns_edge_queue_pop (nns_edge_queue_h handle, void **data, nns_size_t * size)
{
- nns_edge_queue_s *q = (nns_edge_queue_s *) handle;
bool popped = false;
+ nns_edge_queue_s *q = (nns_edge_queue_s *) handle;
if (!q) {
nns_edge_loge ("[Queue] Invalid param, queue is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
if (!data) {
nns_edge_loge ("[Queue] Invalid param, data is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
if (!size) {
nns_edge_loge ("[Queue] Invalid param, size is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
/* init data */
popped = _pop_data (q, false, data, size);
nns_edge_unlock (q);
- return (popped && *data != NULL);
+ if (!popped || *data == NULL)
+ return NNS_EDGE_ERROR_IO;
+ return NNS_EDGE_ERROR_NONE;
}
/**
* @brief Remove and return the first data in queue. If queue is empty, wait until new data is added in the queue.
*/
-bool
+int
nns_edge_queue_wait_pop (nns_edge_queue_h handle, unsigned int timeout,
void **data, nns_size_t * size)
{
if (!q) {
nns_edge_loge ("[Queue] Invalid param, queue is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
if (!data) {
nns_edge_loge ("[Queue] Invalid param, data is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
if (!size) {
nns_edge_loge ("[Queue] Invalid param, size is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
/* init data */
popped = _pop_data (q, false, data, size);
nns_edge_unlock (q);
- return (popped && *data != NULL);
+ if (!popped || *data == NULL)
+ return NNS_EDGE_ERROR_IO;
+ return NNS_EDGE_ERROR_NONE;
}
/**
* @brief Clear all data in the queue.
* @note When this function is called, nns_edge_queue_wait_pop will stop the waiting.
*/
-bool
+int
nns_edge_queue_clear (nns_edge_queue_h handle)
{
nns_edge_queue_s *q = (nns_edge_queue_s *) handle;
if (!q) {
nns_edge_loge ("[Queue] Invalid param, queue is null.");
- return false;
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
nns_edge_lock (q);
_pop_data (q, true, NULL, NULL);
nns_edge_unlock (q);
- return true;
+ return NNS_EDGE_ERROR_NONE;
}
/**
* @brief Create queue.
* @param[out] handle Newly created handle.
- * @return true on success.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
*/
-bool nns_edge_queue_create (nns_edge_queue_h *handle);
+int nns_edge_queue_create (nns_edge_queue_h *handle);
/**
* @brief Destroy queue.
* @param[in] handle The queue handle.
- * @return true on success.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
*/
-bool nns_edge_queue_destroy (nns_edge_queue_h handle);
+int nns_edge_queue_destroy (nns_edge_queue_h handle);
/**
* @brief Get the length of the queue.
* @param[in] handle The queue handle.
* @param[in] limit The max data in queue. Default 0 means unlimited.
* @param[in] leaky The queue leaky option.
- * @return true on success.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
*/
-bool nns_edge_queue_set_limit (nns_edge_queue_h handle, unsigned int limit, nns_edge_queue_leak_e leaky);
+int nns_edge_queue_set_limit (nns_edge_queue_h handle, unsigned int limit, nns_edge_queue_leak_e leaky);
/**
* @brief Add new data into queue.
* @param[in] data The data to be added.
* @param[in] size The size of pushed data.
* @param[in] destroy Nullable, the callback function to release data.
- * @return true on success.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
*/
-bool nns_edge_queue_push (nns_edge_queue_h handle, void *data, nns_size_t size, nns_edge_data_destroy_cb destroy);
+int nns_edge_queue_push (nns_edge_queue_h handle, void *data, nns_size_t size, nns_edge_data_destroy_cb destroy);
/**
* @brief Remove and return the first data in queue.
* @param[in] handle The queue handle.
* @param[out] data The data in the queue.
* @param[out] size The size of data.
- * @return true on success. false if queue is empty.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ * @retval #NNS_EDGE_ERROR_IO
*/
-bool nns_edge_queue_pop (nns_edge_queue_h handle, void **data, nns_size_t *size);
+int nns_edge_queue_pop (nns_edge_queue_h handle, void **data, nns_size_t *size);
/**
* @brief Remove and return the first data in queue. If queue is empty, wait until new data is added in the queue.
* @param[in] timeout The time to wait for new data, in milliseconds. (0 for infinite timeout)
* @param[out] data The data in the queue.
* @param[out] size The size of data.
- * @return true on success.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ * @retval #NNS_EDGE_ERROR_IO
*/
-bool nns_edge_queue_wait_pop (nns_edge_queue_h handle, unsigned int timeout, void **data, nns_size_t *size);
+int nns_edge_queue_wait_pop (nns_edge_queue_h handle, unsigned int timeout, void **data, nns_size_t *size);
/**
* @brief Stop waiting for new data and clear all data in the queue.
* @param[in] handle The queue handle.
- * @return true on success.
+ * @return 0 on success. Otherwise a negative error value.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
* @note When this function is called, nns_edge_queue_wait_pop will stop the waiting.
*/
-bool nns_edge_queue_clear (nns_edge_queue_h handle);
+int nns_edge_queue_clear (nns_edge_queue_h handle);
#ifdef __cplusplus
}
((unsigned int *) data)[j] = i * 10U + j;
}
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data, dsize, nns_edge_free));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data, dsize, nns_edge_free),
+ NNS_EDGE_ERROR_NONE);
}
return NULL;
for (i = 0; i < 5U; i++)
((unsigned int *) data3)[i] = i + 30U;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data1, dsize, NULL));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data1, dsize, NULL), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 1U);
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data2, dsize, NULL));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data2, dsize, NULL), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 2U);
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data3, dsize, NULL));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data3, dsize, NULL), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 3U);
rsize = 0U;
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &result, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &result, &rsize), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 2U);
EXPECT_EQ (result, data1);
EXPECT_EQ (((unsigned int *) result)[i], i + 10U);
rsize = 0U;
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &result, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &result, &rsize), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 1U);
EXPECT_EQ (result, data2);
EXPECT_EQ (((unsigned int *) result)[i], i + 20U);
rsize = 0U;
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &result, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &result, &rsize), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 0U);
EXPECT_EQ (result, data3);
for (i = 0; i < 5U; i++)
EXPECT_EQ (((unsigned int *) result)[i], i + 30U);
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data1, dsize, nns_edge_free));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data1, dsize, nns_edge_free), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 1U);
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data2, dsize, nns_edge_free));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data2, dsize, nns_edge_free), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 2U);
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data3, dsize, nns_edge_free));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data3, dsize, nns_edge_free), NNS_EDGE_ERROR_NONE);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 3U);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
pthread_attr_t attr;
unsigned int i, j, len, retry;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
void *result = NULL;
nns_size_t rsize = 0U;
- EXPECT_TRUE (nns_edge_queue_wait_pop (queue_h, 0U, &result, &rsize));
+ EXPECT_EQ (nns_edge_queue_wait_pop (queue_h, 0U, &result, &rsize), NNS_EDGE_ERROR_NONE);
for (j = 0; j < 5U; j++)
EXPECT_EQ (((unsigned int *) result)[j], i * 10U + j);
len = nns_edge_queue_get_length (queue_h);
} while (len < 3U && retry++ < 200U);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
*/
TEST(edgeQueue, createInvalidParam01_n)
{
- EXPECT_FALSE (nns_edge_queue_create (NULL));
+ EXPECT_EQ (nns_edge_queue_create (NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
}
/**
*/
TEST(edgeQueue, destroyInvalidParam01_n)
{
- EXPECT_FALSE (nns_edge_queue_destroy (NULL));
+ EXPECT_EQ (nns_edge_queue_destroy (NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
}
/**
data = malloc (dsize);
ASSERT_TRUE (data != NULL);
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
- EXPECT_TRUE (nns_edge_queue_set_limit (queue_h, 3U, NNS_EDGE_QUEUE_LEAK_NEW));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
+ EXPECT_EQ (nns_edge_queue_set_limit (queue_h, 3U, NNS_EDGE_QUEUE_LEAK_NEW), NNS_EDGE_ERROR_NONE);
for (i = 0; i < 5U; i++)
nns_edge_queue_push (queue_h, data, dsize, NULL);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 3U);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
SAFE_FREE (data);
}
void *data;
nns_size_t dsize, rsize;
unsigned int i, len;
- bool res;
+ int ret;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
/* leaky option new */
- EXPECT_TRUE (nns_edge_queue_set_limit (queue_h, 3U, NNS_EDGE_QUEUE_LEAK_NEW));
+ EXPECT_EQ (nns_edge_queue_set_limit (queue_h, 3U, NNS_EDGE_QUEUE_LEAK_NEW), NNS_EDGE_ERROR_NONE);
dsize = sizeof (unsigned int);
*((unsigned int *) data) = i + 1;
- res = nns_edge_queue_push (queue_h, data, dsize, nns_edge_free);
+ ret = nns_edge_queue_push (queue_h, data, dsize, nns_edge_free);
if (i < 3U) {
- EXPECT_TRUE (res);
+ EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
} else {
- EXPECT_FALSE (res);
+ EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
SAFE_FREE (data);
}
}
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 3U);
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &data, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, &rsize), NNS_EDGE_ERROR_NONE);
EXPECT_EQ (*((unsigned int *) data), 1U);
SAFE_FREE (data);
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &data, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, &rsize), NNS_EDGE_ERROR_NONE);
EXPECT_EQ (*((unsigned int *) data), 2U);
SAFE_FREE (data);
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &data, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, &rsize), NNS_EDGE_ERROR_NONE);
EXPECT_EQ (*((unsigned int *) data), 3U);
SAFE_FREE (data);
EXPECT_EQ (len, 0U);
/* leaky option old */
- EXPECT_TRUE (nns_edge_queue_set_limit (queue_h, 3U, NNS_EDGE_QUEUE_LEAK_OLD));
+ EXPECT_EQ (nns_edge_queue_set_limit (queue_h, 3U, NNS_EDGE_QUEUE_LEAK_OLD), NNS_EDGE_ERROR_NONE);
for (i = 0; i < 5U; i++) {
data = malloc (dsize);
*((unsigned int *) data) = i + 1;
- EXPECT_TRUE (nns_edge_queue_push (queue_h, data, dsize, nns_edge_free));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data, dsize, nns_edge_free), NNS_EDGE_ERROR_NONE);
}
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 3U);
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &data, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, &rsize), NNS_EDGE_ERROR_NONE);
EXPECT_EQ (*((unsigned int *) data), 3U);
SAFE_FREE (data);
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &data, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, &rsize), NNS_EDGE_ERROR_NONE);
EXPECT_EQ (*((unsigned int *) data), 4U);
SAFE_FREE (data);
- EXPECT_TRUE (nns_edge_queue_pop (queue_h, &data, &rsize));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, &rsize), NNS_EDGE_ERROR_NONE);
EXPECT_EQ (*((unsigned int *) data), 5U);
SAFE_FREE (data);
len = nns_edge_queue_get_length (queue_h);
EXPECT_EQ (len, 0U);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
*/
TEST(edgeQueue, setLimitInvalidParam01_n)
{
- EXPECT_FALSE (nns_edge_queue_set_limit (NULL, 5U, NNS_EDGE_QUEUE_LEAK_NEW));
+ EXPECT_EQ (nns_edge_queue_set_limit (NULL, 5U, NNS_EDGE_QUEUE_LEAK_NEW), NNS_EDGE_ERROR_INVALID_PARAMETER);
}
/**
data = malloc (dsize);
ASSERT_TRUE (data != NULL);
- EXPECT_FALSE (nns_edge_queue_push (NULL, data, dsize, NULL));
+ EXPECT_EQ (nns_edge_queue_push (NULL, data, dsize, NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
SAFE_FREE (data);
}
nns_edge_queue_h queue_h;
nns_size_t dsize;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
dsize = 5 * sizeof (unsigned int);
- EXPECT_FALSE (nns_edge_queue_push (queue_h, NULL, dsize, NULL));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, NULL, dsize, NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
nns_edge_queue_h queue_h;
void *data;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
data = malloc (5 * sizeof (unsigned int));
ASSERT_TRUE (data != NULL);
- EXPECT_FALSE (nns_edge_queue_push (queue_h, data, 0U, NULL));
+ EXPECT_EQ (nns_edge_queue_push (queue_h, data, 0U, NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
SAFE_FREE (data);
}
void *data;
nns_size_t size;
- EXPECT_FALSE (nns_edge_queue_pop (NULL, &data, &size));
+ EXPECT_EQ (nns_edge_queue_pop (NULL, &data, &size), NNS_EDGE_ERROR_INVALID_PARAMETER);
}
/**
nns_edge_queue_h queue_h;
nns_size_t size;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
- EXPECT_FALSE (nns_edge_queue_pop (queue_h, NULL, &size));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, NULL, &size), NNS_EDGE_ERROR_INVALID_PARAMETER);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
nns_edge_queue_h queue_h;
void *data;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
- EXPECT_FALSE (nns_edge_queue_pop (queue_h, &data, NULL));
+ EXPECT_EQ (nns_edge_queue_pop (queue_h, &data, NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
void *data;
nns_size_t size;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
- EXPECT_FALSE (nns_edge_queue_wait_pop (queue_h, 10U, &data, &size));
+ EXPECT_EQ (nns_edge_queue_wait_pop (queue_h, 10U, &data, &size), NNS_EDGE_ERROR_IO);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
void *data;
nns_size_t size;
- EXPECT_FALSE (nns_edge_queue_wait_pop (NULL, 0U, &data, &size));
+ EXPECT_EQ (nns_edge_queue_wait_pop (NULL, 0U, &data, &size), NNS_EDGE_ERROR_INVALID_PARAMETER);
}
/**
nns_edge_queue_h queue_h;
nns_size_t size;
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
- EXPECT_FALSE (nns_edge_queue_wait_pop (queue_h, 0U, NULL, &size));
+ EXPECT_EQ (nns_edge_queue_wait_pop (queue_h, 0U, NULL, &size), NNS_EDGE_ERROR_INVALID_PARAMETER);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**
{
nns_edge_queue_h queue_h;
void *data;
+ EXPECT_EQ (nns_edge_queue_create (&queue_h), NNS_EDGE_ERROR_NONE);
- EXPECT_TRUE (nns_edge_queue_create (&queue_h));
-
- EXPECT_FALSE (nns_edge_queue_wait_pop (queue_h, 0U, &data, NULL));
+ EXPECT_EQ (nns_edge_queue_wait_pop (queue_h, 0U, &data, NULL), NNS_EDGE_ERROR_INVALID_PARAMETER);
- EXPECT_TRUE (nns_edge_queue_destroy (queue_h));
+ EXPECT_EQ (nns_edge_queue_destroy (queue_h), NNS_EDGE_ERROR_NONE);
}
/**