void test__create_slist_auxiliary__null_typename(void** state) { slist_t* pslist = malloc(sizeof(slist_t)); expect_assert_failure(_create_slist_auxiliary(pslist, NULL)); free(pslist); }
void test__create_slist_auxiliary__unregisted_type(void** state) { slist_t* pslist = malloc(sizeof(slist_t)); assert_false(_create_slist_auxiliary(pslist, "_test__create_slist_auxiliary__unregisted_type_t")); free(pslist); }
void test__create_slist_auxiliary__libcstl_builtin(void** state) { slist_t* pslist = malloc(sizeof(slist_t)); assert_true(_create_slist_auxiliary(pslist, "slist_t< vector_t < string_t>> ")); assert_true(strcmp(_GET_SLIST_TYPE_NAME(pslist), "slist_t<vector_t<string_t>>") == 0); assert_true(_slist_is_created(pslist)); slist_destroy(pslist); }
void test__create_slist_auxiliary__c_builtin(void** state) { slist_t* pslist = malloc(sizeof(slist_t)); assert_true(_create_slist_auxiliary(pslist, "double")); assert_true(strcmp(_GET_SLIST_TYPE_NAME(pslist), "double") == 0); assert_true(_slist_is_created(pslist)); slist_destroy(pslist); }
/* slist_t */ void _type_init_slist(const void* cpv_input, void* pv_output) { bool_t b_result = false; assert(cpv_input != NULL && pv_output != NULL); b_result = _create_slist_auxiliary((slist_t*)cpv_input, (char*)pv_output); assert(b_result); /* initialize slist_t */ slist_init((slist_t*)cpv_input); }
void test__create_slist_auxiliary__user_defined_dup(void** state) { slist_t* pslist = NULL; type_duplicate(struct _tag_test__create_slist_auxiliary__user_defined, _test__create_slist_auxiliary__user_defined_t); pslist = malloc(sizeof(slist_t)); assert_true(_create_slist_auxiliary(pslist, "_test__create_slist_auxiliary__user_defined_t")); assert_true(strcmp(_GET_SLIST_TYPE_NAME(pslist), "_test__create_slist_auxiliary__user_defined_t") == 0); assert_true(_slist_is_created(pslist)); slist_destroy(pslist); }
/** * Create slist container. */ slist_t* _create_slist(const char* s_typename) { slist_t* pslist_new = NULL; assert(s_typename != NULL); /* allocate memory for slist */ if ((pslist_new = (slist_t*)malloc(sizeof(slist_t))) == NULL) { return NULL; } if (!_create_slist_auxiliary(pslist_new, s_typename)) { free(pslist_new); return NULL; } return pslist_new; }
void test__create_slist_auxiliary__null_slist_container(void** state) { expect_assert_failure(_create_slist_auxiliary(NULL, "int")); }