/* 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);
}
Exemple #2
0
void test_strpart_2()
{
	const char tmp[] = "x";
	const char *res;

	res = strpart(tmp, NULL);

	CU_ASSERT_PTR_NULL(res);
}
Exemple #3
0
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);
}
Exemple #4
0
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); 
  }
}
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);
}
Exemple #6
0
void
test_pop_stack_empty() {
	stack *stack = stackCreate();

	int *poppedValue = (int*)stackPop(stack);

	CU_ASSERT_EQUAL(stack -> size, 0);
	CU_ASSERT_PTR_NULL(poppedValue);
}
Exemple #7
0
void
test_peek_stack_empty() {
	stack *stack = stackCreate();

	int *position1 = stackPeek(stack);
	
	CU_ASSERT_EQUAL(stack -> size, 0);
	CU_ASSERT_PTR_NULL(position1);
}
/* 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);
}
Exemple #9
0
void test_strpart_1()
{
	const char tmp[] = "x";
	const char *res;

	res = strpart(NULL, tmp);

	CU_ASSERT_PTR_NULL(res);
}
/* 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);
}
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);
}
Exemple #12
0
void test_strpart_5()
{
	const char tmp1[] = "abcdefg";
	const char tmp2[] = "abc";
	const char *res;

	res = strpart(tmp1, tmp2);

	CU_ASSERT_PTR_NULL(res);
}
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);
}
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);
}
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);
}
void ms_tester_create_filters(unsigned int filter_mask) {
	MSSndCardManager *manager;
	MSSndCard *playcard;
	MSSndCard *captcard;

	CREATE_FILTER(FILTER_MASK_FILEPLAY, ms_tester_fileplay, MS_FILE_PLAYER_ID);
	CREATE_FILTER(FILTER_MASK_FILEREC, ms_tester_filerec, MS_FILE_REC_ID);
	CREATE_FILTER(FILTER_MASK_DTMFGEN, ms_tester_dtmfgen, MS_DTMF_GEN_ID);
	CREATE_FILTER(FILTER_MASK_TONEDET, ms_tester_tonedet, MS_TONE_DETECTOR_ID);
	CREATE_FILTER(FILTER_MASK_VOIDSOURCE, ms_tester_voidsource, MS_VOID_SOURCE_ID);
	CREATE_FILTER(FILTER_MASK_VOIDSINK, ms_tester_voidsink, MS_VOID_SINK_ID);
	if (filter_mask & FILTER_MASK_ENCODER) {
		CU_ASSERT_PTR_NULL(ms_tester_encoder);
		ms_tester_encoder = ms_filter_create_encoder(ms_tester_codec_mime);
		CU_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_encoder);
	}
	if (filter_mask & FILTER_MASK_DECODER) {
		CU_ASSERT_PTR_NULL(ms_tester_decoder);
		ms_tester_decoder = ms_filter_create_decoder(ms_tester_codec_mime);
		CU_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_decoder);
	}
	CREATE_FILTER(FILTER_MASK_RTPRECV, ms_tester_rtprecv, MS_RTP_RECV_ID);
	CREATE_FILTER(FILTER_MASK_RTPSEND, ms_tester_rtpsend, MS_RTP_SEND_ID);
	CREATE_FILTER(FILTER_MASK_RESAMPLER, ms_tester_resampler, MS_RESAMPLE_ID);
	if (filter_mask & FILTER_MASK_SOUNDWRITE) {
		CU_ASSERT_PTR_NULL(ms_tester_soundwrite);
		manager = ms_snd_card_manager_get();
		playcard = ms_snd_card_manager_get_default_playback_card(manager);
		CU_ASSERT_PTR_NOT_NULL_FATAL(playcard);
		ms_tester_soundwrite = ms_snd_card_create_writer(playcard);
		CU_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_soundwrite);
	}
	if (filter_mask & FILTER_MASK_SOUNDREAD) {
		CU_ASSERT_PTR_NULL(ms_tester_soundread);
		manager = ms_snd_card_manager_get();
		captcard = ms_snd_card_manager_get_default_capture_card(manager);
		CU_ASSERT_PTR_NOT_NULL_FATAL(captcard);
		ms_tester_soundread = ms_snd_card_create_reader(captcard);
		CU_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_soundread);
	}
}
static void test_string_n_split_when_n_is_less_than_splitted_elements() {
	char *line = "Hola planeta tierra";
	char** substrings = string_n_split(line, 2, " ");

	CU_ASSERT_PTR_NOT_NULL(substrings);
	CU_ASSERT_STRING_EQUAL(substrings[0], "Hola");
	CU_ASSERT_STRING_EQUAL(substrings[1], "planeta tierra");
	CU_ASSERT_PTR_NULL(substrings[2]);

	string_iterate_lines(substrings, (void*) free);
	free(substrings);
}
Exemple #18
0
void test_get_tail
    (
    void
    )
{
uint32_t arr[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
uint32_t i;
list * new_list = make_new_list();
node * cur = get_tail(new_list);
CU_ASSERT_PTR_NOT_NULL(new_list);
CU_ASSERT_PTR_NULL(cur);
for(i = 0; i < 10; i++)
    {
    add(new_list, &(arr[i]));
    }
cur = get_tail(new_list);
CU_ASSERT_PTR_NOT_NULL(cur);
CU_ASSERT_EQUAL(*(uint32_t *)cur->data, arr[9]);
CU_ASSERT_PTR_NULL(cur->next);
CU_ASSERT_PTR_NOT_NULL(cur->prev);
}
/**
 * init_lsit原型: 
 *      bool init_list(seq_list *s_list, const int element_size)
 *
 * init_list函数检查说明:
 *      1. element_size的有效值是正整数.
 *      2. 当element_size输入无效参数时, 返回值为NULL.
 */ 
static void test_init_list(void) 
{
        int element_size = 0;

        /* case 1: element_size = 0 */
        element_size = 0;
        ps_list = init_list(element_size);
        CU_ASSERT_PTR_NULL(ps_list);

        /* case 2: element_size < 0 */ 
        element_size = -1;
        ps_list = init_list(element_size);
        CU_ASSERT_PTR_NULL(ps_list);

        /* case 3: element_size > 0 */
        element_size = 1;
        ps_list = init_list(element_size);
        CU_ASSERT_PTR_NOT_NULL(ps_list);
        CU_ASSERT_EQUAL(ps_list->element_size, element_size);
        CU_ASSERT_EQUAL(ps_list->length, 0);
}
void test_find_opcode_new(void) {
    CSOUND* csound = csoundCreate(NULL);
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##error", "i", "i"));
    CU_ASSERT_PTR_NULL(find_opcode_new(csound, "##error", NULL, "i"));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##xin64", "i", NULL));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##xin256", "i", NULL));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##userOpcode", NULL, NULL));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##array_set", NULL, "k[]k"));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, ">=", "B", "kc"));
    

}
Exemple #21
0
/**
 * La fonction 'tutu' n'existe pas ,donc renvoie NULL
 */
void test_fonction_tutu_biblio(){
    void *bibliotheque;
    int (*fonction_tutu)(int);

    bibliotheque=dlopen("./biblio.so",RTLD_NOW);
    CU_ASSERT_PTR_NOT_NULL(bibliotheque);

    fonction_tutu=dlsym(bibliotheque,"tutu");
    CU_ASSERT_PTR_NULL(fonction_tutu);
    
    dlclose(bibliotheque);
}
Exemple #22
0
void test_llist_add(void) {
  Llist list = NULL;
  Node node;
  node_alloc(&node);
  node.score = 150;
  mpz_set_str(*(node.data), "1234", 10);

  /* list should be NULL */
  CU_ASSERT_PTR_NULL(list);

  /* Add the node to the list */
  llist_add(node, &list);

  /* Look if the data contained in the list are the same than the node added */
  CU_ASSERT_TRUE(node_is_equal(list->value, node));

  /* int i = 1; */
  /* Element *tmp = list; */
  /* while (tmp != NULL) { */
  /*   printf("#n = %d\n", i++); */
  /*   node_print(tmp->value); */
  /*   tmp = tmp->next; */
  /* } */

  /* Add a new node */
  node.score++;
  mpz_set_str(*(node.data), "5678", 10);
  llist_add(node, &list);

  /* Look if the node has been added BEFORE the first one
     (because his score is higher) */
  CU_ASSERT_TRUE(node_is_equal(list->value, node));

  /* Add another node */
  node.score -= 2;
  llist_add(node, &list);

  /* Look if the node at the top has not changed
     (because his score is lower) */
  node.score += 2;
  CU_ASSERT_TRUE(node_is_equal(list->value, node));

  /* i = 0; */
  /* tmp = list; */
  /* while (tmp != NULL) { */
  /*   printf("#n = %d\n", i++); */
  /*   node_print(tmp->value); */
  /*   tmp = tmp->next; */
  /* } */

  llist_free(&list);
  node_free(&node);
}
Exemple #23
0
static void
nvmf_test_find_subsystem(void)
{
	struct spdk_nvmf_subsystem *subsystem;
	//char long_name[MAX_NQN_SIZE];

	CU_ASSERT_PTR_NULL(nvmf_find_subsystem(NULL));
	subsystem = nvmf_find_subsystem("subsystem1");
	CU_ASSERT_EQUAL(subsystem->num, 1);
	CU_ASSERT_STRING_EQUAL(subsystem->subnqn, "subsystem1");
	/* check long name */
	/* segment fault. Comment it */
	/*
	memset(long_name, 'a', MAX_NQN_SIZE);
	subsystem = nvmf_find_subsystem(long_name);
	CU_ASSERT_EQUAL(subsystem->num, 2);
	CU_ASSERT_STRING_EQUAL(subsystem->subnqn, long_name);
	*/
	/* check none-exist subsystem */
	CU_ASSERT_PTR_NULL(nvmf_find_subsystem("fake"));
}
void assertIntArrayEqual(int* a, int* b) {
	if (a == NULL) {
		CU_ASSERT_PTR_NULL(b);
		return;
	}
	if (b == NULL) {
		CU_ASSERT_PTR_NULL(a);
		return;
	}

	int length_a = a[0];
	int length_b = b[0];
	CU_ASSERT_EQUAL(length_a, length_b);
	if (length_a != length_b)
		return;

	int i = 0;
	for (i = 1; i <= length_a; i++) {
		CU_ASSERT_EQUAL(a[i], b[i]);
	}
}
Exemple #25
0
static void test_group(void)
{
    struct address *a;

    a = NULL;
    parseaddr_list("Buddies: Fred Bloggs <*****@*****.**>, Sarah Jane Smith <*****@*****.**>;", &a);

    CU_ASSERT_PTR_NOT_NULL_FATAL(a);
    CU_ASSERT_PTR_NULL(a->name);
    CU_ASSERT_STRING_EQUAL(a->mailbox, "Buddies");
    CU_ASSERT_PTR_NULL(a->domain);

    CU_ASSERT_PTR_NOT_NULL_FATAL(a->next);
    CU_ASSERT_STRING_EQUAL(a->next->name, "Fred Bloggs");
    CU_ASSERT_STRING_EQUAL(a->next->mailbox, "fbloggs");
    CU_ASSERT_STRING_EQUAL(a->next->domain, "fastmail.fm");

    CU_ASSERT_PTR_NOT_NULL_FATAL(a->next->next);
    CU_ASSERT_STRING_EQUAL(a->next->next->name, "Sarah Jane Smith");
    CU_ASSERT_STRING_EQUAL(a->next->next->mailbox, "sjsmith");
    CU_ASSERT_STRING_EQUAL(a->next->next->domain, "gmail.com");

    CU_ASSERT_PTR_NOT_NULL_FATAL(a->next->next->next);
    CU_ASSERT_PTR_NULL(a->next->next->next->name);
    CU_ASSERT_PTR_NULL(a->next->next->next->mailbox);
    CU_ASSERT_PTR_NULL(a->next->next->next->domain);

    CU_ASSERT_PTR_NULL(a->next->next->next->next);

    parseaddr_free(a);
}
Exemple #26
0
static void test_noname(void)
{
    struct address *a;

    a = NULL;
    parseaddr_list("*****@*****.**", &a);
    CU_ASSERT_PTR_NOT_NULL_FATAL(a);
    CU_ASSERT_PTR_NULL(a->name);
    CU_ASSERT_STRING_EQUAL(a->mailbox, "fbloggs");
    CU_ASSERT_STRING_EQUAL(a->domain, "fastmail.fm");
    CU_ASSERT_PTR_NULL(a->next);

    parseaddr_free(a);

    a = NULL;
    parseaddr_list("<*****@*****.**>", &a);
    CU_ASSERT_PTR_NOT_NULL_FATAL(a);
    CU_ASSERT_PTR_NULL(a->name);
    CU_ASSERT_STRING_EQUAL(a->mailbox, "fbloggs");
    CU_ASSERT_STRING_EQUAL(a->domain, "fastmail.fm");
    CU_ASSERT_PTR_NULL(a->next);

    parseaddr_free(a);

    a = NULL;
    parseaddr_list(" <*****@*****.**>", &a);
    CU_ASSERT_PTR_NOT_NULL_FATAL(a);
    CU_ASSERT_PTR_NULL(a->name);
    CU_ASSERT_STRING_EQUAL(a->mailbox, "fbloggs");
    CU_ASSERT_STRING_EQUAL(a->domain, "fastmail.fm");
    CU_ASSERT_PTR_NULL(a->next);

    parseaddr_free(a);

}
/* test object creation and deletion */
void test_om_new_destroy(void) {

    MBIt_objmap *mymap = NULL;

    mymap = MBI_objmap_new();

    CU_ASSERT_PTR_NOT_NULL_FATAL(mymap);
    /* CU_ASSERT_PTR_NULL_FATAL(mymap->map); */
    CU_ASSERT_EQUAL(mymap->top, 0);

    MBI_objmap_destroy(&mymap);
    CU_ASSERT_PTR_NULL(mymap);
}
Exemple #28
0
void test_log_cf(void)
{
	CALC_ELEMENT *t1 = create_number(1.0);
	t1 = create_log(t1);
	CU_ASSERT_PTR_NOT_NULL(t1);
	CU_ASSERT_EQUAL(t1->calc_t, CALC_LOG);
	CU_ASSERT_EQUAL(t1->status, 0);
	CU_ASSERT_EQUAL(t1->value, 1.0);
	CU_ASSERT_PTR_NOT_NULL(t1->left);
	CU_ASSERT_PTR_NULL(t1->right);
	free_calc_element(t1);

	t1 = create_x();
	t1 = create_log(t1);
	CU_ASSERT_PTR_NOT_NULL(t1);
	CU_ASSERT_EQUAL(t1->calc_t, CALC_LOG);
	CU_ASSERT_EQUAL(t1->status, STATUS_X_PRESENT | STATUS_X_IN_LOG);
	CU_ASSERT_EQUAL(t1->value, 1.0);
	CU_ASSERT_PTR_NOT_NULL(t1->left);
	CU_ASSERT_PTR_NULL(t1->right);
	free_calc_element(t1);
}
Exemple #29
0
static void test_entity_without_free(void)
{
    char data[] = "some entity data";
    struct result* result = 0;

    free_called_with = 0;

    result = success_result((void*)data, 0, 0, 0);
    CU_ASSERT_PTR_NOT_NULL_FATAL(result);

    free_result(result);
    CU_ASSERT_PTR_NULL(free_called_with);
}
Exemple #30
0
void test_conf_parse_row(void) {
	service_t* srv = conf_parse_row("a:b:c");

	CU_ASSERT_PTR_NOT_NULL_FATAL(srv);
	CU_ASSERT_STRING_EQUAL(srv->serv, "a");
	CU_ASSERT_STRING_EQUAL(srv->warn, "b");
	CU_ASSERT_STRING_EQUAL(srv->crit, "c");

	service_free(srv);

	srv = conf_parse_row("abc");
	CU_ASSERT_PTR_NULL(srv);
}