当前位置: 首页>>代码示例>>C++>>正文


C++ CU_ASSERT_PTR_NULL函数代码示例

本文整理汇总了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);
}
开发者ID:somebloke,项目名称:flame-libmboard,代码行数:58,代码来源:test_mb_p_iterator_createfiltered.c

示例2: test_strpart_2

void test_strpart_2()
{
	const char tmp[] = "x";
	const char *res;

	res = strpart(tmp, NULL);

	CU_ASSERT_PTR_NULL(res);
}
开发者ID:takeneco,项目名称:uniqos,代码行数:9,代码来源:cmdparse_ut.c

示例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);
}
开发者ID:tps12,项目名称:tripping-sansa,代码行数:18,代码来源:test_result.c

示例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); 
  }
}
开发者ID:Tw1stedL0gic,项目名称:IOOPM-jojoca,代码行数:9,代码来源:treeTest.c

示例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);
}
开发者ID:nnico15m,项目名称:so-commons-library,代码行数:9,代码来源:test_string.c

示例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);
}
开发者ID:CJPoll,项目名称:data_structures,代码行数:9,代码来源:stack_tests.c

示例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);
}
开发者ID:CJPoll,项目名称:data_structures,代码行数:9,代码来源:stack_tests.c

示例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);
}
开发者ID:somebloke,项目名称:flame-libmboard,代码行数:58,代码来源:test_tt_getcount_col.c

示例9: test_strpart_1

void test_strpart_1()
{
	const char tmp[] = "x";
	const char *res;

	res = strpart(NULL, tmp);

	CU_ASSERT_PTR_NULL(res);
}
开发者ID:takeneco,项目名称:uniqos,代码行数:9,代码来源:cmdparse_ut.c

示例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);
}
开发者ID:somebloke,项目名称:flame-libmboard,代码行数:45,代码来源:test_avl_insert.c

示例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);
}
开发者ID:StephenFang,项目名称:Berkeley-version-of-Git,代码行数:56,代码来源:cunittests.c

示例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);
}
开发者ID:takeneco,项目名称:uniqos,代码行数:10,代码来源:cmdparse_ut.c

示例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);
}
开发者ID:yuandong1222,项目名称:DataStructureInC,代码行数:10,代码来源:generalized_list_test.c

示例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);
}
开发者ID:somebloke,项目名称:flame-libmboard,代码行数:43,代码来源:test_avl_memberof.c

示例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);
}
开发者ID:nnico15m,项目名称:so-commons-library,代码行数:11,代码来源:test_string.c


注:本文中的CU_ASSERT_PTR_NULL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。