void test__create_list_auxiliary__libcstl_builtin(void** state)
{
    list_t* plist = malloc(sizeof(list_t));
    assert_true(_create_list_auxiliary(plist, "list_t<   vector_t     <     string_t>>       "));
    assert_true(strcmp(_GET_LIST_TYPE_NAME(plist), "list_t<vector_t<string_t>>") == 0);
    assert_true(_alloc_is_inited(&plist->_t_allocator));

    list_destroy(plist);
}
Example #2
0
void test__create_deque_auxiliary__libcstl_builtin(void** state)
{
    deque_t* pdeq = malloc(sizeof(deque_t));
    assert_true(_create_deque_auxiliary(pdeq, "deque_t<   vector_t     <     string_t>>       "));
    assert_true(strcmp(_GET_DEQUE_TYPE_NAME(pdeq), "deque_t<vector_t<string_t>>") == 0);
    assert_true(_alloc_is_inited(&pdeq->_t_allocator));
    assert_true(_deque_is_created(pdeq));

    deque_destroy(pdeq);
}
void test__create_list_auxiliary__user_defined_dup(void** state)
{
    list_t* plist = NULL;
    type_duplicate(struct _tag_test__create_list_auxiliary__user_defined, _test__create_list_auxiliary__user_defined_t);
    plist = malloc(sizeof(list_t));
    assert_true(_create_list_auxiliary(plist, "_test__create_list_auxiliary__user_defined_t"));
    assert_true(strcmp(_GET_LIST_TYPE_NAME(plist), "_test__create_list_auxiliary__user_defined_t") == 0);
    assert_true(_alloc_is_inited(&plist->_t_allocator));

    list_destroy(plist);
}
Example #4
0
void test__create_deque_auxiliary__user_defined_dup(void** state)
{
    deque_t* pdeq = NULL;
    type_duplicate(struct _tag_test__create_deque_auxiliary__user_defined, _test__create_deque_auxiliary__user_defined_t);
    pdeq = malloc(sizeof(deque_t));
    assert_true(_create_deque_auxiliary(pdeq, "_test__create_deque_auxiliary__user_defined_t"));
    assert_true(strcmp(_GET_DEQUE_TYPE_NAME(pdeq), "_test__create_deque_auxiliary__user_defined_t") == 0);
    assert_true(_alloc_is_inited(&pdeq->_t_allocator));
    assert_true(_deque_is_created(pdeq));

    deque_destroy(pdeq);
}
Example #5
0
/**
 * Test deque is created by create_deque.
 */
bool_t _deque_is_created(const deque_t* cpdeq_deque)
{
    assert(cpdeq_deque != NULL);

    if(cpdeq_deque->_t_typeinfo._t_style != _TYPE_C_BUILTIN &&
       cpdeq_deque->_t_typeinfo._t_style != _TYPE_CSTL_BUILTIN &&
       cpdeq_deque->_t_typeinfo._t_style != _TYPE_USER_DEFINE)
    {
        return false;
    }
    if(cpdeq_deque->_t_typeinfo._pt_type == NULL)
    {
        return false;
    }

    if(cpdeq_deque->_ppby_map != NULL || cpdeq_deque->_t_mapsize != 0)
    {
        return false;
    }

    if(_GET_DEQUE_COREPOS(cpdeq_deque->_t_start) != NULL ||
       _GET_DEQUE_FIRST_POS(cpdeq_deque->_t_start) != NULL ||
       _GET_DEQUE_AFTERLAST_POS(cpdeq_deque->_t_start) != NULL ||
       _GET_DEQUE_MAP_POINTER(cpdeq_deque->_t_start) != NULL ||
       _GET_DEQUE_CONTAINER(cpdeq_deque->_t_start) != NULL ||
       _GET_DEQUE_CONTAINER_TYPE(cpdeq_deque->_t_start) != _DEQUE_CONTAINER ||
       _GET_DEQUE_ITERATOR_TYPE(cpdeq_deque->_t_start) != _RANDOM_ACCESS_ITERATOR)
    {
        return false;
    }
    if(_GET_DEQUE_COREPOS(cpdeq_deque->_t_finish) != NULL ||
       _GET_DEQUE_FIRST_POS(cpdeq_deque->_t_finish) != NULL ||
       _GET_DEQUE_AFTERLAST_POS(cpdeq_deque->_t_finish) != NULL ||
       _GET_DEQUE_MAP_POINTER(cpdeq_deque->_t_finish) != NULL ||
       _GET_DEQUE_CONTAINER(cpdeq_deque->_t_finish) != NULL ||
       _GET_DEQUE_CONTAINER_TYPE(cpdeq_deque->_t_finish) != _DEQUE_CONTAINER ||
       _GET_DEQUE_ITERATOR_TYPE(cpdeq_deque->_t_finish) != _RANDOM_ACCESS_ITERATOR)
    {
        return false;
    }

    return _alloc_is_inited(&cpdeq_deque->_t_allocator);
}
Example #6
0
/**
 * Test vector is created by create_vector.
 */
bool_t _vector_is_created(const vector_t* cpvec_vector)
{
    assert(cpvec_vector != NULL);

    if (cpvec_vector->_t_typeinfo._t_style != _TYPE_C_BUILTIN &&
        cpvec_vector->_t_typeinfo._t_style != _TYPE_CSTL_BUILTIN &&
        cpvec_vector->_t_typeinfo._t_style != _TYPE_USER_DEFINE) {
        return false;
    }

    if (cpvec_vector->_t_typeinfo._pt_type == NULL) {
        return false;
    }

    if (cpvec_vector->_pby_start != NULL || cpvec_vector->_pby_finish != NULL || cpvec_vector->_pby_endofstorage != NULL) {
        return false;
    }

    return _alloc_is_inited(&cpvec_vector->_t_allocator);
}
Example #7
0
/**
 * Test avl tree is created by _create_avl tree.
 */
bool_t _avl_tree_is_created(const _avl_tree_t* cpt_avl_tree)
{
    assert(cpt_avl_tree != NULL);

    if (cpt_avl_tree->_t_typeinfo._t_style != _TYPE_C_BUILTIN &&
        cpt_avl_tree->_t_typeinfo._t_style != _TYPE_CSTL_BUILTIN &&
        cpt_avl_tree->_t_typeinfo._t_style != _TYPE_USER_DEFINE) {
        return false;
    }
    if (cpt_avl_tree->_t_typeinfo._pt_type == NULL) {
        return false;
    }

    if (cpt_avl_tree->_t_avlroot._pt_parent != NULL || cpt_avl_tree->_t_avlroot._pt_left != NULL ||
        cpt_avl_tree->_t_avlroot._pt_right != NULL || cpt_avl_tree->_t_avlroot._un_height != 0 ||
        cpt_avl_tree->_t_nodecount != 0 || cpt_avl_tree->_t_compare != NULL) {
        return false;
    }

    return _alloc_is_inited(&cpt_avl_tree->_t_allocator);
}
Example #8
0
/**
 * Test hashtable is created by _create_hashtable.
 */
bool_t _hashtable_is_created(const _hashtable_t* cpt_hashtable)
{
    assert(cpt_hashtable != NULL);

    if (cpt_hashtable->_t_typeinfo._t_style != _TYPE_C_BUILTIN &&
        cpt_hashtable->_t_typeinfo._t_style != _TYPE_CSTL_BUILTIN &&
        cpt_hashtable->_t_typeinfo._t_style != _TYPE_USER_DEFINE) {
        return false;
    }
    if (cpt_hashtable->_t_typeinfo._pt_type == NULL) {
        return false;
    }

    if (!_vector_is_created(&cpt_hashtable->_vec_bucket)) {
        return false;
    }

    if (cpt_hashtable->_t_nodecount != 0 || cpt_hashtable->_ufun_hash != NULL || cpt_hashtable->_bfun_compare != NULL) {
        return false;
    }

    return _alloc_is_inited(&cpt_hashtable->_t_allocator);
}
Example #9
0
/**
 * Test slist is created by create_slist.
 */
bool_t _slist_is_created(const slist_t* cpslist_slist)
{
    assert(cpslist_slist != NULL);

    if(cpslist_slist->_t_typeinfo._t_style != _TYPE_C_BUILTIN &&
       cpslist_slist->_t_typeinfo._t_style != _TYPE_CSTL_BUILTIN &&
       cpslist_slist->_t_typeinfo._t_style != _TYPE_USER_DEFINE)
    {
        return false;
    }

    if(cpslist_slist->_t_typeinfo._pt_type == NULL)
    {
        return false;
    }

    if(cpslist_slist->_t_head._pt_next != NULL)
    {
        return false;
    }

    return _alloc_is_inited(&cpslist_slist->_t_allocator);
}