本文整理汇总了C++中CU_ASSERT_PTR_NULL函数的典型用法代码示例。如果您正苦于以下问题:C++ CU_ASSERT_PTR_NULL函数的具体用法?C++ CU_ASSERT_PTR_NULL怎么用?C++ CU_ASSERT_PTR_NULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CU_ASSERT_PTR_NULL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_mb_p_iter_create_filtered
/* Test MB_Iterator_CreateFiltered */
void test_mb_p_iter_create_filtered(void) {
int rc;
MBIt_Board *board;
MBIt_Iterator *iterator;
filter_params fp;
fp.lb = TEST_FILTER_LB;
fp.ub = TEST_FILTER_UB;
/* Try invalid mboard */
mb_f = 99999999;
rc = MB_Iterator_CreateFiltered(mb_f, &itr_f, &my_filter, &fp);
CU_ASSERT_EQUAL(rc, MB_ERR_INVALID);
CU_ASSERT_EQUAL(itr_f, MB_NULL_ITERATOR);
/* Try NULL mboard */
mb_f = MB_NULL_MBOARD;
rc = MB_Iterator_CreateFiltered(mb_f, &itr_f, &my_filter, &fp);
CU_ASSERT_EQUAL(rc, MB_ERR_INVALID);
CU_ASSERT_EQUAL(itr_f, MB_NULL_ITERATOR);
/* Populate mboard. Abort on failure */
rc = init_mb_with_content(&mb_f);
CU_ASSERT_EQUAL_FATAL(rc, MB_SUCCESS);
/* Try locked board */
board = (MBIt_Board *)MBI_getMBoardRef(mb_f);
CU_ASSERT_PTR_NOT_NULL_FATAL(board);
board->locked = MB_TRUE;
rc = MB_Iterator_CreateFiltered(mb_f, &itr_f, &my_filter, &fp);
CU_ASSERT_EQUAL(rc, MB_ERR_LOCKED);
CU_ASSERT_EQUAL(itr_f, MB_NULL_ITERATOR);
board->locked = MB_FALSE;
/* Try on "unreadable" boards */
board->is_reader = MB_FALSE;
rc = MB_Iterator_Create(mb_f, &itr_f);
CU_ASSERT_EQUAL(rc, MB_ERR_DISABLED);
CU_ASSERT_EQUAL(itr_f, MB_NULL_ITERATOR);
board->is_reader = MB_TRUE;
/* Create sorted Iterator */
itr_f = MB_NULL_ITERATOR;
rc = MB_Iterator_CreateFiltered(mb_f, &itr_f, &my_filter, &fp);
CU_ASSERT_EQUAL(rc, MB_SUCCESS);
CU_ASSERT_NOT_EQUAL(itr_f, MB_NULL_ITERATOR);
board = (MBIt_Board *)MBI_getMBoardRef(mb_f);
iterator = (MBIt_Iterator *)MBI_getIteratorRef(itr_f);
CU_ASSERT_PTR_NOT_NULL_FATAL(board);
CU_ASSERT_PTR_NOT_NULL_FATAL(iterator);
CU_ASSERT_EQUAL(board->data->elem_size, iterator->msgsize);
CU_ASSERT_EQUAL(iterator->iterating, 0);
CU_ASSERT_PTR_NULL(iterator->cursor);
CU_ASSERT_EQUAL(iterator->mb, mb_f);
}
示例2: test_strpart_2
void test_strpart_2()
{
const char tmp[] = "x";
const char *res;
res = strpart(tmp, NULL);
CU_ASSERT_PTR_NULL(res);
}
示例3: test_success_with_entity
static void test_success_with_entity(void)
{
char* data = malloc(32);
struct result* result = 0;
sprintf(data, "some entity data");
result = success_result((void*)data, &free_data, 0, 0);
CU_ASSERT_PTR_NOT_NULL_FATAL(result);
CU_ASSERT_PTR_NULL(result->error);
CU_ASSERT_PTR_EQUAL(result->data, data);
CU_ASSERT_PTR_EQUAL(result->free_data, &free_data);
CU_ASSERT_PTR_NULL(result->location);
free_result(result);
free(data);
}
示例4: s_test_create_tree_fail
void s_test_create_tree_fail(void){
int sizeOfElement = sizeof(int);
Tree tree = new_tree(sizeOfElement, NULL, NULL, NULL, NULL);
CU_ASSERT_PTR_NULL(tree);
if (tree != NULL) {
destroy_tree(&tree);
}
}
示例5: test_string_n_split_is_empty
static void test_string_n_split_is_empty() {
char* line = "";
char** substrings = string_n_split(line, 10, ";");
CU_ASSERT_PTR_NOT_NULL(substrings);
CU_ASSERT_PTR_NULL(substrings[0]);
free(substrings);
}
示例6: test_pop_stack_empty
void
test_pop_stack_empty() {
stack *stack = stackCreate();
int *poppedValue = (int*)stackPop(stack);
CU_ASSERT_EQUAL(stack -> size, 0);
CU_ASSERT_PTR_NULL(poppedValue);
}
示例7: test_peek_stack_empty
void
test_peek_stack_empty() {
stack *stack = stackCreate();
int *position1 = stackPeek(stack);
CU_ASSERT_EQUAL(stack -> size, 0);
CU_ASSERT_PTR_NULL(position1);
}
示例8: test_tt_getcount_col
/* test test_tt_getcount_col() */
void test_tt_getcount_col(void) {
int i, j, rc;
int count = 999;
int rows = 10;
int cols = rows * 8;
tag_table *tt = NULL;
char octet1 = (char)0x00;
char octet2 = (char)0xff;
/* create the tt object */
rc = tt_create(&tt, rows, cols);
CU_ASSERT_EQUAL_FATAL(rc, TT_SUCCESS);
CU_ASSERT_PTR_NOT_NULL_FATAL(tt);
/* check count for newly created table */
for (i = 0; i < cols; i++)
{
rc = tt_getcount_col(tt, i, &count);
if (rc != TT_SUCCESS) CU_FAIL("tt_getcount() returned with an error");
if (count != 0) CU_FAIL("count != 0");
}
/* systematically set various bits within the table */
for (i = 0; i < rows; i++)
{
for (j = 0; j < (int)tt->row_size; j++)
{
if (i % 2 == 0)
{
rc = tt_setbyte(tt, i, j, octet1);
if (rc != TT_SUCCESS) CU_FAIL("tt_setbits() returned an error code");
}
else
{
rc = tt_setbyte(tt, i, j, octet2);
if (rc != TT_SUCCESS) CU_FAIL("tt_setbits() returned an error code");
}
}
}
/* recheck count for table */
for (i = 0; i < cols; i++)
{
rc = tt_getcount_col(tt, i, &count);
if (rc != TT_SUCCESS) CU_FAIL("tt_getcount() returned with an error");
if (count != (rows / 2)) CU_FAIL("count != rows/2");
}
/* destroy tt object */
rc = tt_delete(&tt);
CU_ASSERT_EQUAL(rc, TT_SUCCESS);
CU_ASSERT_PTR_NULL(tt);
}
示例9: test_strpart_1
void test_strpart_1()
{
const char tmp[] = "x";
const char *res;
res = strpart(NULL, tmp);
CU_ASSERT_PTR_NULL(res);
}
示例10: test_avl_insert_withptr
/* we expect _getnode() to have been tested before this test is called */
void test_avl_insert_withptr(void) {
int i, errcount;
int *data;
int testvals[TEST_AVL_TREESIZE];
MBIt_AVLtree *tree = NULL;
MBIt_AVLnode *node = NULL;
/* create tree */
tree = MBI_AVLtree_create();
CU_ASSERT_PTR_NOT_NULL_FATAL(tree);
CU_ASSERT_EQUAL(tree->count, 0);
CU_ASSERT_PTR_NULL(tree->root);
/* it shouldn't matter if we do get duplicate values in the tree */
for (i = 0; i < TEST_AVL_TREESIZE; i++)
{
testvals[i] = i * 10; /* remember values used */
MBI_AVLtree_insert(tree, i, &testvals[i]);
}
/* use getnode to retrieve node pointer and inspect key value */
errcount = 0;
for (i = 0; i < TEST_AVL_TREESIZE; i++)
{
node = MBI_AVLtree_getnode(tree, i);
if (node == NULL)
{
errcount += 1;
continue;
}
if (node->key != i) errcount += 1;
if (node->data == NULL) {errcount += 1; continue;}
data = (int*)node->data;
if (*data != (i * 10)) errcount += 1;
}
CU_ASSERT_EQUAL(errcount, 0);
/* destroy tree */
MBI_AVLtree_destroy(&tree);
CU_ASSERT_PTR_NULL(tree);
}
示例11: simple_log_test
void simple_log_test(void)
{
struct commit* commit_list = NULL;
int retval;
retval = beargit_init();
CU_ASSERT(0==retval);
FILE* asdf = fopen("asdf.txt", "w");
fclose(asdf);
retval = beargit_add("asdf.txt");
CU_ASSERT(0==retval);
run_commit(&commit_list, "GO BEARS!1");
run_commit(&commit_list, "GO BEARS!2");
run_commit(&commit_list, "GO BEARS!3");
retval = beargit_log(INT_MAX);
CU_ASSERT(0==retval);
struct commit* cur_commit = commit_list;
const int LINE_SIZE = 512;
char line[LINE_SIZE];
FILE* fstdout = fopen("TEST_STDOUT", "r");
CU_ASSERT_PTR_NOT_NULL(fstdout);
while (cur_commit != NULL) {
char refline[LINE_SIZE];
// First line is empty
CU_ASSERT_PTR_NOT_NULL(fgets(line, LINE_SIZE, fstdout));
CU_ASSERT(!strcmp(line,"\n"));
// Second line is commit -- don't check the ID.
CU_ASSERT_PTR_NOT_NULL(fgets(line, LINE_SIZE, fstdout));
CU_ASSERT(!strncmp(line,"commit", strlen("commit")));
// Third line is msg
sprintf(refline, " %s\n", cur_commit->msg);
CU_ASSERT_PTR_NOT_NULL(fgets(line, LINE_SIZE, fstdout));
CU_ASSERT_STRING_EQUAL(line, refline);
cur_commit = cur_commit->next;
}
// Last line is empty
CU_ASSERT_PTR_NOT_NULL(fgets(line, LINE_SIZE, fstdout));
CU_ASSERT(!strcmp(line,"\n"));
CU_ASSERT_PTR_NULL(fgets(line, LINE_SIZE, fstdout));
// It's the end of output
CU_ASSERT(feof(fstdout));
fclose(fstdout);
free_commit_list(&commit_list);
}
示例12: test_strpart_5
void test_strpart_5()
{
const char tmp1[] = "abcdefg";
const char tmp2[] = "abc";
const char *res;
res = strpart(tmp1, tmp2);
CU_ASSERT_PTR_NULL(res);
}
示例13: test_Destory
void test_Destory(void) {
Status status = ERROR;
GENERALIZED_LIST_TYPE list = getGeneralizedList("(1,2,3,4)");
if (list == NULL)
return;
status = Destory(&list);
CU_ASSERT_EQUAL(status, OK);
CU_ASSERT_PTR_NULL(list);
}
示例14: test_avl_memberof
void test_avl_memberof(void) {
int i, errcount, v;
int testvals[TEST_AVL_TREESIZE];
MBIt_AVLtree *tree = NULL;
tree = MBI_AVLtree_create();
CU_ASSERT_PTR_NOT_NULL_FATAL(tree);
CU_ASSERT_EQUAL(tree->count, 0);
CU_ASSERT_PTR_NULL(tree->root);
/* get list of unique random ints */
generate_random_unique_ints(testvals, TEST_AVL_TREESIZE);
/* add nodes */
for (i = 0; i < TEST_AVL_TREESIZE; i++)
{
MBI_AVLtree_insert(tree, testvals[i], NULL);
}
check_tree_integrity(tree);
/* try checking with 2 * TEST_AVL_TREESIZE random values */
errcount = 0;
for (i = 0; i < TEST_AVL_TREESIZE * 2; i++)
{
v = rand();
if (_in_array(testvals, TEST_AVL_TREESIZE, v) !=
MBI_AVLtree_memberof(tree, v)) errcount++;
}
CU_ASSERT_EQUAL(errcount, 0);
/* check againts all actual values */
for (i = 0; i < TEST_AVL_TREESIZE; i++)
{
v = testvals[i];
if (! MBI_AVLtree_memberof(tree, v)) errcount++;
}
CU_ASSERT_EQUAL(errcount, 0);
MBI_AVLtree_destroy(&tree);
CU_ASSERT_PTR_NULL(tree);
}
示例15: test_string_n_split_when_separator_isnt_included
static void test_string_n_split_when_separator_isnt_included() {
char *line = "Hola planeta tierra";
char ** substrings = string_n_split(line, 5, ";");
CU_ASSERT_PTR_NOT_NULL(substrings);
CU_ASSERT_STRING_EQUAL(substrings[0], line);
CU_ASSERT_PTR_NULL(substrings[1]);
string_iterate_lines(substrings, (void *) free);
free(substrings);
}