#include "test.h"
#if INCLUDE_LIST_TEST
#include <pjlib.h>
{
int value;
static int compare_node(
void *value,
const pj_list_type *nd)
{
return ((
long)(
pj_ssize_t)value == node->value) ? 0 : -1;
}
#define PJ_SIGNED_ARRAY_SIZE(a) ((int)PJ_ARRAY_SIZE(a))
int list_test()
{
int i;
list.value = (unsigned)-1;
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
nodes[i].value = i;
}
for (i=0, p=list.next; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i, p=p->next) {
if (p->value != i) {
return -1;
}
}
for (i=PJ_SIGNED_ARRAY_SIZE(nodes)-1; i>=0; --i) {
}
for (i=0, p=list.next; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i, p=p->next) {
if (p->value != i) {
return -1;
}
}
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes)/2; ++i) {
}
for (i=PJ_SIGNED_ARRAY_SIZE(nodes)/2; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
}
for (i=0, p=list.next; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i, p=p->next) {
if (p->value != i) {
return -1;
}
}
return -1;
}
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes)/2; ++i) {
}
for (i=PJ_SIGNED_ARRAY_SIZE(nodes)/2; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
}
for (i=0, p=list2.next; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i, p=p->next) {
if (p->value != i) {
return -1;
}
}
return -1;
}
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes)/2; ++i) {
}
for (i=PJ_SIGNED_ARRAY_SIZE(nodes)/2+1; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
}
for (i=0, p=list.next; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i, p=p->next) {
if (p->value != i) {
return -1;
}
}
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
nodes[i].value = i;
}
for (i=PJ_SIGNED_ARRAY_SIZE(nodes)-1; i>=0; --i) {
int j;
for (j=0, p=list.next; j<i; ++j, p=p->next) {
if (p->value != j) {
return -1;
}
}
}
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
nodes[i].value = i;
}
for (i=0; i<PJ_SIGNED_ARRAY_SIZE(nodes); ++i) {
if (p != &nodes[i]) {
return -1;
}
&compare_node);
if (p != &nodes[i]) {
return -1;
}
}
return 0;
}
#else
int dummy_list_test;
#endif
long pj_ssize_t
Definition: types.h:64
void pj_list_type
Definition: types.h:157
void pj_list_init(pj_list_type *node)
Definition: list.h:87
void pj_list_erase(pj_list_type *node)
void pj_list_merge_first(pj_list_type *list1, pj_list_type *list2)
void pj_list_insert_nodes_before(pj_list_type *lst, pj_list_type *nodes)
void pj_list_insert_after(pj_list_type *pos, pj_list_type *node)
int pj_list_empty(const pj_list_type *node)
Definition: list.h:101
pj_list_type * pj_list_search(pj_list_type *list, void *value, int(*comp)(void *value, const pj_list_type *node))
void pj_list_merge_last(pj_list_type *list1, pj_list_type *list2)
pj_list_type * pj_list_find_node(pj_list_type *list, pj_list_type *node)
void pj_list_insert_before(pj_list_type *pos, pj_list_type *node)
#define pj_assert(expr)
Definition: assert.h:48
Definition: pjlib-test/list.c:51