mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-12-04 14:46:31 -05:00
Update: Updated igloo_ro_unref to use igloo_error_t
This commit is contained in:
parent
2c2f477ed7
commit
b8ce49e64e
@ -299,7 +299,7 @@ int igloo_ro_ref(igloo_ro_t self);
|
|||||||
/* This decreases the reference counter of the object.
|
/* This decreases the reference counter of the object.
|
||||||
* If the object's reference counter reaches zero the object is freed.
|
* If the object's reference counter reaches zero the object is freed.
|
||||||
*/
|
*/
|
||||||
int igloo_ro_unref(igloo_ro_t self);
|
igloo_error_t igloo_ro_unref(igloo_ro_t self);
|
||||||
|
|
||||||
/* This is the same as igloo_ro_ref() and igloo_ro_unref() but increases/decreases the weak reference counter. */
|
/* This is the same as igloo_ro_ref() and igloo_ro_unref() but increases/decreases the weak reference counter. */
|
||||||
igloo_error_t igloo_ro_weak_ref(igloo_ro_t self);
|
igloo_error_t igloo_ro_weak_ref(igloo_ro_t self);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <igloo/reportxml.h>
|
#include <igloo/reportxml.h>
|
||||||
#include <igloo/thread.h>
|
#include <igloo/thread.h>
|
||||||
#include <igloo/avl.h>
|
#include <igloo/avl.h>
|
||||||
|
#include <igloo/error.h>
|
||||||
|
|
||||||
#define XMLSTR(str) ((xmlChar *)(str))
|
#define XMLSTR(str) ((xmlChar *)(str))
|
||||||
|
|
||||||
@ -956,12 +957,17 @@ xmlNodePtr igloo_reportxml_node_get_xml_child(igloo_reportxml_node_
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __database_free_key_fun_type(void * key)
|
||||||
|
{
|
||||||
|
return igloo_ro_unref(key) == igloo_ERROR_NONE ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void __database_free(igloo_ro_t self)
|
static void __database_free(igloo_ro_t self)
|
||||||
{
|
{
|
||||||
igloo_reportxml_database_t *db = igloo_RO_TO_TYPE(self, igloo_reportxml_database_t);
|
igloo_reportxml_database_t *db = igloo_RO_TO_TYPE(self, igloo_reportxml_database_t);
|
||||||
|
|
||||||
if (db->definitions)
|
if (db->definitions)
|
||||||
igloo_avl_tree_free(db->definitions, (igloo_avl_free_key_fun_type)igloo_ro_unref);
|
igloo_avl_tree_free(db->definitions, __database_free_key_fun_type);
|
||||||
|
|
||||||
igloo_thread_mutex_destroy(&(db->lock));
|
igloo_thread_mutex_destroy(&(db->lock));
|
||||||
}
|
}
|
||||||
|
10
src/ro.c
10
src/ro.c
@ -159,24 +159,24 @@ static inline void igloo_ro__destory(igloo_ro_base_t *base)
|
|||||||
free(base);
|
free(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
int igloo_ro_unref(igloo_ro_t self)
|
igloo_error_t igloo_ro_unref(igloo_ro_t self)
|
||||||
{
|
{
|
||||||
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
|
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
|
||||||
|
|
||||||
if (!base)
|
if (!base)
|
||||||
return -1;
|
return igloo_ERROR_FAULT;
|
||||||
|
|
||||||
igloo_thread_mutex_lock(&(base->lock));
|
igloo_thread_mutex_lock(&(base->lock));
|
||||||
|
|
||||||
if (!base->refc) {
|
if (!base->refc) {
|
||||||
igloo_thread_mutex_unlock(&(base->lock));
|
igloo_thread_mutex_unlock(&(base->lock));
|
||||||
return -1;
|
return igloo_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base->refc > 1) {
|
if (base->refc > 1) {
|
||||||
base->refc--;
|
base->refc--;
|
||||||
igloo_thread_mutex_unlock(&(base->lock));
|
igloo_thread_mutex_unlock(&(base->lock));
|
||||||
return 0;
|
return igloo_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base->type->type_freecb)
|
if (base->type->type_freecb)
|
||||||
@ -198,7 +198,7 @@ int igloo_ro_unref(igloo_ro_t self)
|
|||||||
igloo_ro__destory(base);
|
igloo_ro__destory(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return igloo_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
igloo_error_t igloo_ro_weak_ref(igloo_ro_t self)
|
igloo_error_t igloo_ro_weak_ref(igloo_ro_t self)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <igloo/ro.h>
|
#include <igloo/ro.h>
|
||||||
#include <igloo/buffer.h>
|
#include <igloo/buffer.h>
|
||||||
|
#include <igloo/error.h>
|
||||||
|
|
||||||
static void test_create_ref_unref(void)
|
static void test_create_ref_unref(void)
|
||||||
{
|
{
|
||||||
@ -23,11 +24,11 @@ static void test_create_ref_unref(void)
|
|||||||
|
|
||||||
a = igloo_buffer_new(-1, NULL, igloo_RO_NULL);
|
a = igloo_buffer_new(-1, NULL, igloo_RO_NULL);
|
||||||
ctest_test("buffer created", a != NULL);
|
ctest_test("buffer created", a != NULL);
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
a = igloo_ro_new(igloo_buffer_t);
|
a = igloo_ro_new(igloo_buffer_t);
|
||||||
ctest_test("buffer created", a != NULL);
|
ctest_test("buffer created", a != NULL);
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ static void test_name(void)
|
|||||||
ctest_test("get name", ret != NULL);
|
ctest_test("get name", ret != NULL);
|
||||||
ctest_test("name match", strcmp(name, ret) == 0);
|
ctest_test("name match", strcmp(name, ret) == 0);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_associated(void)
|
static void test_associated(void)
|
||||||
@ -59,8 +60,8 @@ static void test_associated(void)
|
|||||||
b = igloo_buffer_new(-1, NULL, a);
|
b = igloo_buffer_new(-1, NULL, a);
|
||||||
ctest_test("buffer created with associated", !igloo_RO_IS_NULL(b));
|
ctest_test("buffer created with associated", !igloo_RO_IS_NULL(b));
|
||||||
|
|
||||||
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_empty(void)
|
static void test_empty(void)
|
||||||
@ -104,7 +105,7 @@ static void test_empty(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_string(void)
|
static void test_string(void)
|
||||||
@ -139,7 +140,7 @@ static void test_string(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_binary(void)
|
static void test_binary(void)
|
||||||
@ -183,7 +184,7 @@ static void test_binary(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test__compare_to_string(igloo_buffer_t *a, const char *testname, const char *pattern)
|
static void test__compare_to_string(igloo_buffer_t *a, const char *testname, const char *pattern)
|
||||||
@ -222,7 +223,7 @@ static void test_shift(void)
|
|||||||
test__compare_to_string(a, "string matches shifted input", pattern + 2 + 3 + 2);
|
test__compare_to_string(a, "string matches shifted input", pattern + 2 + 3 + 2);
|
||||||
ctest_test("shifted data beyond end (42 bytes)", igloo_buffer_shift(a, 42) != 0);
|
ctest_test("shifted data beyond end (42 bytes)", igloo_buffer_shift(a, 42) != 0);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_length(void)
|
static void test_length(void)
|
||||||
@ -247,7 +248,7 @@ static void test_length(void)
|
|||||||
ctest_test("Set length to match pattern a (again)", igloo_buffer_set_length(a, strlen(match_a)) != 0);
|
ctest_test("Set length to match pattern a (again)", igloo_buffer_set_length(a, strlen(match_a)) != 0);
|
||||||
test__compare_to_string(a, "string still matches pattern c", match_c);
|
test__compare_to_string(a, "string still matches pattern c", match_c);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_printf(void)
|
static void test_printf(void)
|
||||||
@ -269,7 +270,7 @@ static void test_printf(void)
|
|||||||
ctest_test("Set length to match pattern a", igloo_buffer_push_printf(a, "?%+5i?", -num) == 0);
|
ctest_test("Set length to match pattern a", igloo_buffer_push_printf(a, "?%+5i?", -num) == 0);
|
||||||
test__compare_to_string(a, "string matches pattern c", match_c);
|
test__compare_to_string(a, "string matches pattern c", match_c);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_push_buffer(void)
|
static void test_push_buffer(void)
|
||||||
@ -293,8 +294,8 @@ static void test_push_buffer(void)
|
|||||||
ctest_test("pushed buffer a to b", igloo_buffer_push_buffer(b, a) == 0);
|
ctest_test("pushed buffer a to b", igloo_buffer_push_buffer(b, a) == 0);
|
||||||
test__compare_to_string(b, "string matches pattern a", match_a);
|
test__compare_to_string(b, "string matches pattern a", match_a);
|
||||||
|
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <igloo/ro.h>
|
#include <igloo/ro.h>
|
||||||
#include <igloo/list.h>
|
#include <igloo/list.h>
|
||||||
|
#include <igloo/error.h>
|
||||||
|
|
||||||
static void test_create_ref_unref(void)
|
static void test_create_ref_unref(void)
|
||||||
{
|
{
|
||||||
@ -24,7 +25,7 @@ static void test_create_ref_unref(void)
|
|||||||
a = igloo_ro_new(igloo_list_t);
|
a = igloo_ro_new(igloo_list_t);
|
||||||
ctest_test("list created", !igloo_RO_IS_NULL(a));
|
ctest_test("list created", !igloo_RO_IS_NULL(a));
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test__create_push_unshift(igloo_list_t **list, igloo_ro_base_t **a, igloo_ro_base_t **b)
|
static void test__create_push_unshift(igloo_list_t **list, igloo_ro_base_t **a, igloo_ro_base_t **b)
|
||||||
@ -55,9 +56,9 @@ static void test_list_push_unshift(void)
|
|||||||
|
|
||||||
test__create_push_unshift(&list, &a, &b);
|
test__create_push_unshift(&list, &a, &b);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_push_unshift_pop(void)
|
static void test_list_push_unshift_pop(void)
|
||||||
@ -72,11 +73,11 @@ static void test_list_push_unshift_pop(void)
|
|||||||
ret = igloo_list_pop(list);
|
ret = igloo_list_pop(list);
|
||||||
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_push_unshift_pop_pop(void)
|
static void test_list_push_unshift_pop_pop(void)
|
||||||
@ -91,20 +92,20 @@ static void test_list_push_unshift_pop_pop(void)
|
|||||||
ret = igloo_list_pop(list);
|
ret = igloo_list_pop(list);
|
||||||
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_pop(list);
|
ret = igloo_list_pop(list);
|
||||||
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("popped element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("popped element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_pop(list);
|
ret = igloo_list_pop(list);
|
||||||
ctest_test("popped no element", igloo_RO_IS_NULL(ret));
|
ctest_test("popped no element", igloo_RO_IS_NULL(ret));
|
||||||
igloo_ro_unref(ret); /* just in case we got an element */
|
igloo_ro_unref(ret); /* just in case we got an element */
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_push_unshift_shift(void)
|
static void test_list_push_unshift_shift(void)
|
||||||
@ -119,11 +120,11 @@ static void test_list_push_unshift_shift(void)
|
|||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_push_unshift_shift_shift(void)
|
static void test_list_push_unshift_shift_shift(void)
|
||||||
@ -138,20 +139,20 @@ static void test_list_push_unshift_shift_shift(void)
|
|||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("shifted element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted no element", igloo_RO_IS_NULL(ret));
|
ctest_test("shifted no element", igloo_RO_IS_NULL(ret));
|
||||||
igloo_ro_unref(ret); /* just in case we got an element */
|
igloo_ro_unref(ret); /* just in case we got an element */
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -167,16 +168,16 @@ static void test_list_push_unshift_pop_shift(void)
|
|||||||
ret = igloo_list_pop(list);
|
ret = igloo_list_pop(list);
|
||||||
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
static void test_list_push_unshift_shift_pop(void)
|
static void test_list_push_unshift_shift_pop(void)
|
||||||
{
|
{
|
||||||
@ -190,16 +191,16 @@ static void test_list_push_unshift_shift_pop(void)
|
|||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_pop(list);
|
ret = igloo_list_pop(list);
|
||||||
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
ctest_test("popped element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("popped element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced popped element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_merge(void)
|
static void test_list_merge(void)
|
||||||
@ -230,12 +231,12 @@ static void test_list_merge(void)
|
|||||||
ret = igloo_list_shift(list_a);
|
ret = igloo_list_shift(list_a);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("shifted element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_shift(list_a);
|
ret = igloo_list_shift(list_a);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_shift(list_a);
|
ret = igloo_list_shift(list_a);
|
||||||
ctest_test("shifted no element", igloo_RO_IS_NULL(ret));
|
ctest_test("shifted no element", igloo_RO_IS_NULL(ret));
|
||||||
@ -244,16 +245,16 @@ static void test_list_merge(void)
|
|||||||
ret = igloo_list_shift(list_b);
|
ret = igloo_list_shift(list_b);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
ctest_test("shifted element matches b", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == b);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ret = igloo_list_shift(list_b);
|
ret = igloo_list_shift(list_b);
|
||||||
ctest_test("shifted no element", igloo_RO_IS_NULL(ret));
|
ctest_test("shifted no element", igloo_RO_IS_NULL(ret));
|
||||||
igloo_ro_unref(ret); /* just in case we got an element */
|
igloo_ro_unref(ret); /* just in case we got an element */
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list a", igloo_ro_unref(list_a) == 0);
|
ctest_test("un-referenced list a", igloo_ro_unref(list_a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list b", igloo_ro_unref(list_b) == 0);
|
ctest_test("un-referenced list b", igloo_ro_unref(list_b) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_set_type(void)
|
static void test_list_set_type(void)
|
||||||
@ -290,7 +291,7 @@ static void test_list_set_type(void)
|
|||||||
ctest_test("can not pin list to type igloo_list_t", igloo_list_set_type(list, igloo_list_t) == 0);
|
ctest_test("can not pin list to type igloo_list_t", igloo_list_set_type(list, igloo_list_t) == 0);
|
||||||
ctest_test("pinned list to type igloo_ro_base_t", igloo_list_set_type(list, igloo_ro_base_t) == 0);
|
ctest_test("pinned list to type igloo_ro_base_t", igloo_list_set_type(list, igloo_ro_base_t) == 0);
|
||||||
|
|
||||||
ctest_test("un-referenced list a", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list a", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
list = igloo_ro_new(igloo_list_t);
|
list = igloo_ro_new(igloo_list_t);
|
||||||
ctest_test("list created", !igloo_RO_IS_NULL(list));
|
ctest_test("list created", !igloo_RO_IS_NULL(list));
|
||||||
|
|
||||||
@ -304,15 +305,15 @@ static void test_list_set_type(void)
|
|||||||
ret = igloo_list_shift(list);
|
ret = igloo_list_shift(list);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(ret));
|
||||||
ctest_test("shifted element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
ctest_test("shifted element matches a", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == a);
|
||||||
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced shifted element", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("pinned list to type igloo_ro_base_t", igloo_list_set_type(list, igloo_ro_base_t) != 0);
|
ctest_test("pinned list to type igloo_ro_base_t", igloo_list_set_type(list, igloo_ro_base_t) != 0);
|
||||||
ctest_test("can not pin list to type igloo_list_t", igloo_list_set_type(list, igloo_list_t) == 0);
|
ctest_test("can not pin list to type igloo_list_t", igloo_list_set_type(list, igloo_list_t) == 0);
|
||||||
ctest_test("pinned list to type igloo_ro_base_t", igloo_list_set_type(list, igloo_ro_base_t) != 0);
|
ctest_test("pinned list to type igloo_ro_base_t", igloo_list_set_type(list, igloo_ro_base_t) != 0);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list a", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list a", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_iterator(void)
|
static void test_list_iterator(void)
|
||||||
@ -332,7 +333,7 @@ static void test_list_iterator(void)
|
|||||||
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
||||||
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
||||||
if (!igloo_RO_IS_NULL(ret)) {
|
if (!igloo_RO_IS_NULL(ret)) {
|
||||||
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +343,7 @@ static void test_list_iterator(void)
|
|||||||
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
||||||
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
||||||
if (!igloo_RO_IS_NULL(ret)) {
|
if (!igloo_RO_IS_NULL(ret)) {
|
||||||
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +353,7 @@ static void test_list_iterator(void)
|
|||||||
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
||||||
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
||||||
if (!igloo_RO_IS_NULL(ret)) {
|
if (!igloo_RO_IS_NULL(ret)) {
|
||||||
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,15 +363,15 @@ static void test_list_iterator(void)
|
|||||||
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
igloo_ro_t ret = igloo_list_iterator_next(iterator);
|
||||||
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
ctest_test("shifted element matches corresponding element in list", igloo_RO_TO_TYPE(ret, igloo_ro_base_t) == elements[i]);
|
||||||
if (!igloo_RO_IS_NULL(ret)) {
|
if (!igloo_RO_IS_NULL(ret)) {
|
||||||
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == 0);
|
ctest_test("un-referenced element returned by iterator", igloo_ro_unref(ret) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
igloo_list_iterator_end(iterator);
|
igloo_list_iterator_end(iterator);
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(elements[0]) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(elements[0]) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(elements[1]) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(elements[1]) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_foreach(void)
|
static void test_list_foreach(void)
|
||||||
@ -386,9 +387,9 @@ static void test_list_foreach(void)
|
|||||||
i++;
|
i++;
|
||||||
});
|
});
|
||||||
|
|
||||||
ctest_test("un-referenced a", igloo_ro_unref(elements[0]) == 0);
|
ctest_test("un-referenced a", igloo_ro_unref(elements[0]) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced b", igloo_ro_unref(elements[1]) == 0);
|
ctest_test("un-referenced b", igloo_ro_unref(elements[1]) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_policy_grow(void) {
|
static void test_list_policy_grow(void) {
|
||||||
@ -404,10 +405,10 @@ static void test_list_policy_grow(void) {
|
|||||||
igloo_ro_base_t *element = igloo_ro_new(igloo_ro_base_t);
|
igloo_ro_base_t *element = igloo_ro_new(igloo_ro_base_t);
|
||||||
ctest_test("test object created", !igloo_RO_IS_NULL(element));
|
ctest_test("test object created", !igloo_RO_IS_NULL(element));
|
||||||
ctest_test("test object pushed", igloo_list_push(list, element) == 0);
|
ctest_test("test object pushed", igloo_list_push(list, element) == 0);
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_policy_fixed(void) {
|
static void test_list_policy_fixed(void) {
|
||||||
@ -429,12 +430,12 @@ static void test_list_policy_fixed(void) {
|
|||||||
} else {
|
} else {
|
||||||
ctest_test("test object can not be pushed", igloo_list_push(list, element) != 0);
|
ctest_test("test object can not be pushed", igloo_list_push(list, element) != 0);
|
||||||
}
|
}
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
element = igloo_RO_TO_TYPE(igloo_list_shift(list), igloo_ro_base_t);
|
element = igloo_RO_TO_TYPE(igloo_list_shift(list), igloo_ro_base_t);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(element));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(element));
|
||||||
ctest_test("un-referenced element", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced element", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
element = igloo_ro_new(igloo_ro_base_t);
|
element = igloo_ro_new(igloo_ro_base_t);
|
||||||
@ -444,10 +445,10 @@ static void test_list_policy_fixed(void) {
|
|||||||
} else {
|
} else {
|
||||||
ctest_test("test object can not be pushed", igloo_list_push(list, element) != 0);
|
ctest_test("test object can not be pushed", igloo_list_push(list, element) != 0);
|
||||||
}
|
}
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_policy_fixed_pipe_push(void) {
|
static void test_list_policy_fixed_pipe_push(void) {
|
||||||
@ -472,16 +473,16 @@ static void test_list_policy_fixed_pipe_push(void) {
|
|||||||
ctest_test("referenced 2nd test object", igloo_ro_ref(second_element) == 0);
|
ctest_test("referenced 2nd test object", igloo_ro_ref(second_element) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
element = igloo_RO_TO_TYPE(igloo_list_shift(list), igloo_ro_base_t);
|
element = igloo_RO_TO_TYPE(igloo_list_shift(list), igloo_ro_base_t);
|
||||||
ctest_test("shifted element", !igloo_RO_IS_NULL(element));
|
ctest_test("shifted element", !igloo_RO_IS_NULL(element));
|
||||||
ctest_test("shifted element matches 2nd test object", igloo_RO_TO_TYPE(element, igloo_ro_base_t) == second_element);
|
ctest_test("shifted element matches 2nd test object", igloo_RO_TO_TYPE(element, igloo_ro_base_t) == second_element);
|
||||||
ctest_test("un-referenced element", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced element", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced 2nd test object", igloo_ro_unref(second_element) == 0);
|
ctest_test("un-referenced 2nd test object", igloo_ro_unref(second_element) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_policy_fixed_pipe_unshift(void) {
|
static void test_list_policy_fixed_pipe_unshift(void) {
|
||||||
@ -506,16 +507,16 @@ static void test_list_policy_fixed_pipe_unshift(void) {
|
|||||||
ctest_test("referenced 2nd test object", igloo_ro_ref(second_element) == 0);
|
ctest_test("referenced 2nd test object", igloo_ro_ref(second_element) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
element = igloo_RO_TO_TYPE(igloo_list_pop(list), igloo_ro_base_t);
|
element = igloo_RO_TO_TYPE(igloo_list_pop(list), igloo_ro_base_t);
|
||||||
ctest_test("poped element", !igloo_RO_IS_NULL(element));
|
ctest_test("poped element", !igloo_RO_IS_NULL(element));
|
||||||
ctest_test("poped element matches 2nd test object", igloo_RO_TO_TYPE(element, igloo_ro_base_t) == second_element);
|
ctest_test("poped element matches 2nd test object", igloo_RO_TO_TYPE(element, igloo_ro_base_t) == second_element);
|
||||||
ctest_test("un-referenced element", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced element", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced 2nd test object", igloo_ro_unref(second_element) == 0);
|
ctest_test("un-referenced 2nd test object", igloo_ro_unref(second_element) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_policy_fixed_pipe_merge(void) {
|
static void test_list_policy_fixed_pipe_merge(void) {
|
||||||
@ -536,7 +537,7 @@ static void test_list_policy_fixed_pipe_merge(void) {
|
|||||||
element = igloo_ro_new(igloo_ro_base_t);
|
element = igloo_ro_new(igloo_ro_base_t);
|
||||||
ctest_test("test object created", !igloo_RO_IS_NULL(element));
|
ctest_test("test object created", !igloo_RO_IS_NULL(element));
|
||||||
ctest_test("test object pushed", igloo_list_push(srclist, element) == 0);
|
ctest_test("test object pushed", igloo_list_push(srclist, element) == 0);
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("merged source list into destination list", igloo_list_merge(dstlist, srclist) == 0);
|
ctest_test("merged source list into destination list", igloo_list_merge(dstlist, srclist) == 0);
|
||||||
@ -546,8 +547,8 @@ static void test_list_policy_fixed_pipe_merge(void) {
|
|||||||
|
|
||||||
ctest_test("merged source list into destination list", igloo_list_merge(dstlist, srclist) == 0);
|
ctest_test("merged source list into destination list", igloo_list_merge(dstlist, srclist) == 0);
|
||||||
|
|
||||||
ctest_test("un-referenced srclist", igloo_ro_unref(srclist) == 0);
|
ctest_test("un-referenced srclist", igloo_ro_unref(srclist) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced dstlist", igloo_ro_unref(dstlist) == 0);
|
ctest_test("un-referenced dstlist", igloo_ro_unref(dstlist) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_list_remove(void) {
|
static void test_list_remove(void) {
|
||||||
@ -570,7 +571,7 @@ static void test_list_remove(void) {
|
|||||||
ctest_test("referenced 2nd test object", igloo_ro_ref(second_element) == 0);
|
ctest_test("referenced 2nd test object", igloo_ro_ref(second_element) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced test object", igloo_ro_unref(element) == 0);
|
ctest_test("un-referenced test object", igloo_ro_unref(element) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("2nd element was removed", igloo_list_remove(list, second_element) == 0);
|
ctest_test("2nd element was removed", igloo_list_remove(list, second_element) == 0);
|
||||||
@ -583,8 +584,8 @@ static void test_list_remove(void) {
|
|||||||
|
|
||||||
ctest_test("Number of returned elements is correct", count == 3);
|
ctest_test("Number of returned elements is correct", count == 3);
|
||||||
|
|
||||||
ctest_test("un-referenced 2nd test object", igloo_ro_unref(second_element) == 0);
|
ctest_test("un-referenced 2nd test object", igloo_ro_unref(second_element) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced list", igloo_ro_unref(list) == 0);
|
ctest_test("un-referenced list", igloo_ro_unref(list) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <igloo/logmsg.h>
|
#include <igloo/logmsg.h>
|
||||||
#include <igloo/filter.h>
|
#include <igloo/filter.h>
|
||||||
|
#include <igloo/error.h>
|
||||||
|
|
||||||
static void test_create_unref(void)
|
static void test_create_unref(void)
|
||||||
{
|
{
|
||||||
@ -25,15 +26,15 @@ static void test_create_unref(void)
|
|||||||
|
|
||||||
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL__NONE, igloo_LOGMSG_OPT_NONE, NULL, "test");
|
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL__NONE, igloo_LOGMSG_OPT_NONE, NULL, "test");
|
||||||
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
|
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(msg) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
formater = igloo_logmsg_formarter(igloo_RO_NULL, NULL, NULL, igloo_RO_NULL);
|
formater = igloo_logmsg_formarter(igloo_RO_NULL, NULL, NULL, igloo_RO_NULL);
|
||||||
ctest_test("formater created", !igloo_RO_IS_NULL(formater));
|
ctest_test("formater created", !igloo_RO_IS_NULL(formater));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(formater) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(formater) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
filter = igloo_logmsg_filter(igloo_LOGLEVEL__NONE, igloo_LOGLEVEL__NONE, igloo_LOGMSG_OPT_NONE, igloo_LOGMSG_OPT_NONE, NULL, NULL, NULL, NULL, igloo_RO_NULL);
|
filter = igloo_logmsg_filter(igloo_LOGLEVEL__NONE, igloo_LOGLEVEL__NONE, igloo_LOGMSG_OPT_NONE, igloo_LOGMSG_OPT_NONE, NULL, NULL, NULL, NULL, igloo_RO_NULL);
|
||||||
ctest_test("filter created", !igloo_RO_IS_NULL(filter));
|
ctest_test("filter created", !igloo_RO_IS_NULL(filter));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(filter) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(filter) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_logmsg(void)
|
static void test_logmsg(void)
|
||||||
@ -86,7 +87,7 @@ static void test_logmsg(void)
|
|||||||
ctest_test("got referenced", 0);
|
ctest_test("got referenced", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(msg) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_filter(void)
|
static void test_filter(void)
|
||||||
@ -101,19 +102,19 @@ static void test_filter(void)
|
|||||||
base = igloo_ro_new(igloo_ro_base_t);
|
base = igloo_ro_new(igloo_ro_base_t);
|
||||||
ctest_test("base created", base != NULL);
|
ctest_test("base created", base != NULL);
|
||||||
ctest_test("droping base", igloo_filter_test(filter, base) == igloo_FILTER_RESULT_DROP);
|
ctest_test("droping base", igloo_filter_test(filter, base) == igloo_FILTER_RESULT_DROP);
|
||||||
ctest_test("base un-referenced", igloo_ro_unref(base) == 0);
|
ctest_test("base un-referenced", igloo_ro_unref(base) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL_INFO, igloo_LOGMSG_OPT_NONE, NULL, "test");
|
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL_INFO, igloo_LOGMSG_OPT_NONE, NULL, "test");
|
||||||
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
|
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
|
||||||
ctest_test("droping logmsg", igloo_filter_test(filter, msg) == igloo_FILTER_RESULT_DROP);
|
ctest_test("droping logmsg", igloo_filter_test(filter, msg) == igloo_FILTER_RESULT_DROP);
|
||||||
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(msg) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL_WARN, igloo_LOGMSG_OPT_NONE, NULL, "test");
|
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL_WARN, igloo_LOGMSG_OPT_NONE, NULL, "test");
|
||||||
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
|
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
|
||||||
ctest_test("passing logmsg", igloo_filter_test(filter, msg) == igloo_FILTER_RESULT_PASS);
|
ctest_test("passing logmsg", igloo_filter_test(filter, msg) == igloo_FILTER_RESULT_PASS);
|
||||||
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(msg) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(filter) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(filter) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
|
@ -33,6 +33,7 @@ typedef struct ctest_test_type_d_t ctest_test_type_d_t;
|
|||||||
igloo_RO_TYPE(ctest_test_type_d_t)
|
igloo_RO_TYPE(ctest_test_type_d_t)
|
||||||
|
|
||||||
#include <igloo/ro.h>
|
#include <igloo/ro.h>
|
||||||
|
#include <igloo/error.h>
|
||||||
|
|
||||||
struct ctest_test_type_t {
|
struct ctest_test_type_t {
|
||||||
igloo_ro_base_t __base;
|
igloo_ro_base_t __base;
|
||||||
@ -100,8 +101,8 @@ static void test_create_ref_unref(void)
|
|||||||
ctest_test("refobject created", !igloo_RO_IS_NULL(a));
|
ctest_test("refobject created", !igloo_RO_IS_NULL(a));
|
||||||
|
|
||||||
ctest_test("referenced", igloo_ro_ref(a) == 0);
|
ctest_test("referenced", igloo_ro_ref(a) == 0);
|
||||||
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_create_weak_ref_unref(void)
|
static void test_create_weak_ref_unref(void)
|
||||||
@ -112,9 +113,9 @@ static void test_create_weak_ref_unref(void)
|
|||||||
ctest_test("refobject created", !igloo_RO_IS_NULL(a));
|
ctest_test("refobject created", !igloo_RO_IS_NULL(a));
|
||||||
|
|
||||||
ctest_test("weak referenced", igloo_ro_weak_ref(a) == 0);
|
ctest_test("weak referenced", igloo_ro_weak_ref(a) == 0);
|
||||||
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("referencing failed", igloo_ro_ref(a) != 0);
|
ctest_test("referencing failed", igloo_ro_ref(a) != 0);
|
||||||
ctest_test("un-referencing (2 of 2) failed", igloo_ro_unref(a) != 0);
|
ctest_test("un-referencing (2 of 2) failed", igloo_ro_unref(a) != igloo_ERROR_NONE);
|
||||||
ctest_test("weak un-referenced", igloo_ro_weak_unref(a) == 0);
|
ctest_test("weak un-referenced", igloo_ro_weak_unref(a) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ static void test_typename(void)
|
|||||||
ctest_test("got typename", typename != NULL);
|
ctest_test("got typename", typename != NULL);
|
||||||
ctest_test("typename matches", strcmp(typename, "igloo_ro_base_t") == 0);
|
ctest_test("typename matches", strcmp(typename, "igloo_ro_base_t") == 0);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_valid(void)
|
static void test_valid(void)
|
||||||
@ -145,7 +146,7 @@ static void test_valid(void)
|
|||||||
ctest_test("is valid", igloo_RO_IS_VALID(a, igloo_ro_base_t));
|
ctest_test("is valid", igloo_RO_IS_VALID(a, igloo_ro_base_t));
|
||||||
ctest_test("is valid as diffrent type", !igloo_RO_IS_VALID(a, ctest_test_type_t));
|
ctest_test("is valid as diffrent type", !igloo_RO_IS_VALID(a, ctest_test_type_t));
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_sizes(void)
|
static void test_sizes(void)
|
||||||
@ -154,22 +155,22 @@ static void test_sizes(void)
|
|||||||
|
|
||||||
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_a_t);
|
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_a_t);
|
||||||
ctest_test("refobject created with size=sizeof(igloo_ro_base_t) + 1024", !igloo_RO_IS_NULL(a));
|
ctest_test("refobject created with size=sizeof(igloo_ro_base_t) + 1024", !igloo_RO_IS_NULL(a));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_b_t);
|
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_b_t);
|
||||||
ctest_test("refobject created with size=sizeof(igloo_ro_base_t) + 131072", !igloo_RO_IS_NULL(a));
|
ctest_test("refobject created with size=sizeof(igloo_ro_base_t) + 131072", !igloo_RO_IS_NULL(a));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_c_t);
|
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_c_t);
|
||||||
ctest_test("refobject created with size=sizeof(igloo_ro_base_t) - 1", igloo_RO_IS_NULL(a));
|
ctest_test("refobject created with size=sizeof(igloo_ro_base_t) - 1", igloo_RO_IS_NULL(a));
|
||||||
if (!igloo_RO_IS_NULL(a)) {
|
if (!igloo_RO_IS_NULL(a)) {
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_d_t);
|
a = (igloo_ro_t)igloo_ro_new(ctest_test_type_d_t);
|
||||||
ctest_test("refobject created with size=0", igloo_RO_IS_NULL(a));
|
ctest_test("refobject created with size=0", igloo_RO_IS_NULL(a));
|
||||||
if (!igloo_RO_IS_NULL(a)) {
|
if (!igloo_RO_IS_NULL(a)) {
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ static void test_name(void)
|
|||||||
ctest_test("get name", ret != NULL);
|
ctest_test("get name", ret != NULL);
|
||||||
ctest_test("name match", strcmp(name, ret) == 0);
|
ctest_test("name match", strcmp(name, ret) == 0);
|
||||||
|
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_associated(void)
|
static void test_associated(void)
|
||||||
@ -199,8 +200,8 @@ static void test_associated(void)
|
|||||||
b = igloo_ro_new_ext(igloo_ro_base_t, NULL, a);
|
b = igloo_ro_new_ext(igloo_ro_base_t, NULL, a);
|
||||||
ctest_test("refobject created with associated", !igloo_RO_IS_NULL(b));
|
ctest_test("refobject created with associated", !igloo_RO_IS_NULL(b));
|
||||||
|
|
||||||
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(b) == 0);
|
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(b) == igloo_ERROR_NONE);
|
||||||
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t test_freecb__called;
|
static size_t test_freecb__called;
|
||||||
@ -216,7 +217,7 @@ static void test_freecb(void)
|
|||||||
test_freecb__called = 0;
|
test_freecb__called = 0;
|
||||||
a = igloo_ro_new(ctest_test_type_free_t);
|
a = igloo_ro_new(ctest_test_type_free_t);
|
||||||
ctest_test("refobject created", a != NULL);
|
ctest_test("refobject created", a != NULL);
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("freecb called", test_freecb__called == 1);
|
ctest_test("freecb called", test_freecb__called == 1);
|
||||||
|
|
||||||
test_freecb__called = 0;
|
test_freecb__called = 0;
|
||||||
@ -224,9 +225,9 @@ static void test_freecb(void)
|
|||||||
ctest_test("refobject created", a != NULL);
|
ctest_test("refobject created", a != NULL);
|
||||||
ctest_test("referenced", igloo_ro_ref(a) == 0);
|
ctest_test("referenced", igloo_ro_ref(a) == 0);
|
||||||
ctest_test("freecb uncalled", test_freecb__called == 0);
|
ctest_test("freecb uncalled", test_freecb__called == 0);
|
||||||
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (1 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("freecb uncalled", test_freecb__called == 0);
|
ctest_test("freecb uncalled", test_freecb__called == 0);
|
||||||
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced (2 of 2)", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("freecb called", test_freecb__called == 1);
|
ctest_test("freecb called", test_freecb__called == 1);
|
||||||
|
|
||||||
test_freecb__called = 0;
|
test_freecb__called = 0;
|
||||||
@ -234,7 +235,7 @@ static void test_freecb(void)
|
|||||||
ctest_test("refobject created", a != NULL);
|
ctest_test("refobject created", a != NULL);
|
||||||
ctest_test("weak referenced", igloo_ro_weak_ref(a) == 0);
|
ctest_test("weak referenced", igloo_ro_weak_ref(a) == 0);
|
||||||
ctest_test("freecb uncalled", test_freecb__called == 0);
|
ctest_test("freecb uncalled", test_freecb__called == 0);
|
||||||
ctest_test("un-referenced", igloo_ro_unref(a) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE);
|
||||||
ctest_test("freecb called", test_freecb__called == 1);
|
ctest_test("freecb called", test_freecb__called == 1);
|
||||||
ctest_test("weak un-referenced", igloo_ro_weak_unref(a) == 0);
|
ctest_test("weak un-referenced", igloo_ro_weak_unref(a) == 0);
|
||||||
ctest_test("freecb called once", test_freecb__called == 1);
|
ctest_test("freecb called once", test_freecb__called == 1);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "ctest_lib.h"
|
#include "ctest_lib.h"
|
||||||
|
|
||||||
#include <igloo/reportxml.h>
|
#include <igloo/reportxml.h>
|
||||||
|
#include <igloo/error.h>
|
||||||
|
|
||||||
static void test_create_unref(void)
|
static void test_create_unref(void)
|
||||||
{
|
{
|
||||||
@ -24,15 +25,15 @@ static void test_create_unref(void)
|
|||||||
|
|
||||||
report = igloo_ro_new(igloo_reportxml_t);
|
report = igloo_ro_new(igloo_reportxml_t);
|
||||||
ctest_test("report created", !igloo_RO_IS_NULL(report));
|
ctest_test("report created", !igloo_RO_IS_NULL(report));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(report) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(report) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
node = igloo_reportxml_node_new(igloo_REPORTXML_NODE_TYPE_REPORT, NULL, NULL, NULL);
|
node = igloo_reportxml_node_new(igloo_REPORTXML_NODE_TYPE_REPORT, NULL, NULL, NULL);
|
||||||
ctest_test("node created", !igloo_RO_IS_NULL(node));
|
ctest_test("node created", !igloo_RO_IS_NULL(node));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(node) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(node) == igloo_ERROR_NONE);
|
||||||
|
|
||||||
database = igloo_ro_new(igloo_reportxml_database_t);
|
database = igloo_ro_new(igloo_reportxml_database_t);
|
||||||
ctest_test("database created", !igloo_RO_IS_NULL(database));
|
ctest_test("database created", !igloo_RO_IS_NULL(database));
|
||||||
ctest_test("un-referenced", igloo_ro_unref(database) == 0);
|
ctest_test("un-referenced", igloo_ro_unref(database) == igloo_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
|
Loading…
Reference in New Issue
Block a user