void test_next_nonEmptyList(void) { list_t* lista = list_init(); addElement(lista, (void*)a); addElement(lista, (void*)b); addElement(lista, (void*)c); iterator_t* i=iterator_init(lista); payload_t * corrente = next(i); CU_ASSERT_PTR_NOT_NULL(corrente); CU_ASSERT_PTR_EQUAL(corrente, lista->head->payload); corrente = next(i); CU_ASSERT_PTR_NOT_NULL(corrente); CU_ASSERT_PTR_EQUAL(corrente, lista->head->next->payload); corrente = next(i); CU_ASSERT_PTR_NOT_NULL(corrente); CU_ASSERT_PTR_EQUAL(corrente, lista->tail->payload); corrente = next(i); CU_ASSERT_PTR_NULL(corrente); iterator_destroy(i); list_destroy(lista); }
void test_pl_create_delete(void) { int rc; pooled_list *pl = NULL; rc = pl_create(&pl, sizeof(my_message_t), ELEM_COUNT_DEFAULT); /* make sure object creation successful before proceeding */ CU_ASSERT_EQUAL_FATAL(rc, PL_SUCCESS); CU_ASSERT_PTR_NOT_NULL_FATAL(pl); /* Check all default internal values */ CU_ASSERT((int)pl->elem_size == (int)sizeof(my_message_t)); CU_ASSERT(pl->elem_count == ELEM_COUNT_DEFAULT); CU_ASSERT(pl->count_free == ELEM_COUNT_DEFAULT); CU_ASSERT(pl->count_total == ELEM_COUNT_DEFAULT); CU_ASSERT(pl->count_current == 0); /* Check address node list */ CU_ASSERT_PTR_NOT_NULL(pl->addr_list); /* address node exists */ CU_ASSERT_PTR_NULL(pl->addr_list->next); /* no second node */ CU_ASSERT_PTR_NOT_NULL(pl->addr_list->addr); /* memory block allocated */ CU_ASSERT_PTR_EQUAL(pl->active_memblock, pl->addr_list); /*active blk set*/ /* check datablock pointers */ CU_ASSERT_PTR_NULL(pl->head); /* head pointer unset */ CU_ASSERT_PTR_NULL(pl->tail); /* tail pointer unset */ CU_ASSERT_PTR_EQUAL(pl->next_free, pl->addr_list->addr); /* next_free set */ destroy_pl_object(&pl); }
void t_sendqueue9(void) { coap_queue_t *tmp_node; struct coap_context_t ctx; /* Initialize a fake context that points to our global sendqueue * Note that all changes happen on ctx.sendqueue. */ ctx.sendqueue = sendqueue; tmp_node = coap_peek_next(&ctx); sendqueue = ctx.sendqueue; /* must update global sendqueue for correct result */ CU_ASSERT_PTR_NOT_NULL(tmp_node); CU_ASSERT_PTR_EQUAL(tmp_node, node[1]); CU_ASSERT_PTR_EQUAL(tmp_node, ctx.sendqueue); tmp_node = coap_pop_next(&ctx); sendqueue = ctx.sendqueue; /* must update global sendqueue for correct result */ CU_ASSERT_PTR_NOT_NULL(tmp_node); CU_ASSERT_PTR_EQUAL(tmp_node, node[1]); CU_ASSERT_PTR_NOT_NULL(sendqueue); CU_ASSERT_PTR_EQUAL(sendqueue, node[2]); CU_ASSERT(tmp_node->t == timestamp[1]); CU_ASSERT(sendqueue->t == timestamp[2]); CU_ASSERT_PTR_NULL(sendqueue->next); }
void bi_list_test_remove(void) { TBiList list; TBiElement head; TBiElement element; TBiElement tail; bi_list_ctor(&list); bi_element_ctor(&head); bi_element_ctor(&element); bi_element_ctor(&tail); bi_list_push_back(&list, &head); bi_list_push_back(&list, &element); bi_list_push_back(&list, &tail); bi_list_remove(&list, &element); /* check if head is predecessor of tail */ CU_ASSERT_PTR_EQUAL(&head, tail.prev); /* check if tail is successor of head */ CU_ASSERT_PTR_EQUAL(&tail, head.next); }
void bi_list_test_push_back_next(void) { TBiList list; TBiElement head; TBiElement next; bi_list_ctor(&list); bi_element_ctor(&head); bi_element_ctor(&next); bi_list_push_back(&list, &head); TBiElement* oldTail = list.tail; bi_list_push_back(&list, &next); /* check if list is not empty */ CU_ASSERT_EQUAL(0, bi_list_empty(&list)); /* check if next is a new tail of the list */ CU_ASSERT_PTR_EQUAL(&next, list.tail); /* check if on the list are more than one element */ CU_ASSERT_PTR_NOT_EQUAL(list.head, list.tail); /* check if oldTail is the predecessor of next */ CU_ASSERT_PTR_EQUAL(oldTail, next.prev); /* check if next is a successor of the oldTail */ CU_ASSERT_PTR_EQUAL(&next, oldTail->next); }
void bi_list_test_pop_front_head(void) { TBiList list; TBiElement head; TBiElement tail; bi_list_ctor(&list); bi_element_ctor(&head); bi_element_ctor(&tail); bi_list_push_front(&list, &head); bi_list_push_front(&list, &tail); TBiElement* old_head = list.head; TBiElement* old_head_next = old_head->next; TBiElement* front = bi_list_pop_front(&list); /* check if front is not 0 */ CU_ASSERT_PTR_NOT_EQUAL(0, front); /* check if front is the old_head */ CU_ASSERT_PTR_EQUAL(front, old_head); /* check if new head is the successor of the old_head */ CU_ASSERT_PTR_EQUAL(old_head_next, list.head); }
void bi_list_test_insert(void) { TBiList list; TBiElement head; TBiElement tail; TBiElement element; bi_list_ctor(&list); bi_element_ctor(&head); bi_element_ctor(&tail); bi_element_ctor(&element); bi_list_push_back(&list, &head); bi_list_push_back(&list, &tail); bi_list_insert(&list, &head, &element); /* check if element is successor of head */ CU_ASSERT_PTR_EQUAL(head.next, &element); /* check if head is predecessor of element */ CU_ASSERT_PTR_EQUAL(&head, element.prev); /* check if element is predecessor of tail */ CU_ASSERT_PTR_EQUAL(tail.prev, &element); /* check if tail is successor of element */ CU_ASSERT_PTR_EQUAL(&tail, element.next); }
void bi_list_test_pop_back_tail(void) { TBiList list; TBiElement head; TBiElement tail; bi_list_ctor(&list); bi_element_ctor(&head); bi_element_ctor(&tail); bi_list_push_back(&list, &head); bi_list_push_back(&list, &tail); TBiElement* old_tail = list.tail; TBiElement* old_tail_prev = old_tail->prev; TBiElement* back = bi_list_pop_back(&list); /* check if back is not 0 */ CU_ASSERT_PTR_NOT_EQUAL(0, back); /* check if back is the old_tail */ CU_ASSERT_PTR_EQUAL(back, old_tail); /* check if new tail is the predecessor of the old_tail */ CU_ASSERT_PTR_EQUAL(old_tail_prev, list.tail); }
void bi_list_test_push_front_next(void) { TBiList list; TBiElement head; TBiElement next; bi_list_ctor(&list); bi_element_ctor(&head); bi_element_ctor(&next); bi_list_push_front(&list, &head); TBiElement* old_head = list.head; bi_list_push_front(&list, &next); /* check if list is not empty */ CU_ASSERT_EQUAL(0, bi_list_empty(&list)); /* check if next is a new head of the list */ CU_ASSERT_PTR_EQUAL(&next, list.head); /* check if on the list are more than one element */ CU_ASSERT_PTR_NOT_EQUAL(list.head, list.tail); /* check if old_head is the successor of next */ CU_ASSERT_PTR_EQUAL(old_head, next.next); /* check if next is a predecessor of the old_head */ CU_ASSERT_PTR_EQUAL(&next, old_head->prev); }
/* insert new node as fourth element in queue */ void t_sendqueue4(void) { int result; result = coap_insert_node(&sendqueue, node[4]); CU_ASSERT(result > 0); CU_ASSERT_PTR_EQUAL(sendqueue, node[3]); CU_ASSERT_PTR_NOT_NULL(sendqueue->next); CU_ASSERT_PTR_EQUAL(sendqueue->next, node[1]); CU_ASSERT_PTR_NOT_NULL(sendqueue->next->next); CU_ASSERT_PTR_EQUAL(sendqueue->next->next, node[4]); CU_ASSERT_PTR_NOT_NULL(sendqueue->next->next->next); CU_ASSERT_PTR_EQUAL(sendqueue->next->next->next, node[2]); CU_ASSERT(sendqueue->next->t == timestamp[1] - timestamp[3]); CU_ASSERT(add_timestamps(sendqueue, 1) == timestamp[3]); CU_ASSERT(add_timestamps(sendqueue, 2) == timestamp[1]); CU_ASSERT(add_timestamps(sendqueue, 3) == timestamp[4]); CU_ASSERT(add_timestamps(sendqueue, 4) == timestamp[2]); }
PRIVATE void test_layout_locate(void) { const struct flash_layout *l = &__test_layout; struct flash_loc loc = {0xFF}; CU_ASSERT_EQUAL( flash_layout__locate(l, 0, &loc), E_GOOD ); CU_ASSERT_EQUAL( loc.abs, 0 ); CU_ASSERT_EQUAL( loc.c, 0 ); CU_ASSERT_EQUAL( loc.s, 0 ); CU_ASSERT_EQUAL( loc.p, 0 ); CU_ASSERT_EQUAL( loc.o, 0 ); CU_ASSERT_PTR_EQUAL(loc.ly, l); CU_ASSERT_EQUAL( flash_layout__locate(l, 4, &loc), E_GOOD ); CU_ASSERT_EQUAL( loc.c, 0 ); CU_ASSERT_EQUAL( loc.s, 0 ); CU_ASSERT_EQUAL( loc.p, 0 ); CU_ASSERT_EQUAL( loc.o, 4 ); CU_ASSERT_PTR_EQUAL(loc.ly, l); CU_ASSERT_EQUAL( flash_layout__locate(l, 0x020405, &loc), E_GOOD); CU_ASSERT_EQUAL( loc.abs, 0x020405 ); CU_ASSERT_EQUAL( loc.c, 0 ); CU_ASSERT_EQUAL( loc.s, 2 ); CU_ASSERT_EQUAL( loc.p, 4 ); CU_ASSERT_EQUAL( loc.o, 5 ); CU_ASSERT_PTR_EQUAL(loc.ly, l); CU_ASSERT_NOT_EQUAL( flash_layout__locate(l, 0x01000000, &loc), E_GOOD ); }
void test_dequeue_back() { Dequeue *dequeue = createDequeue(); int value1 = 1; int value2 = 2; int value3 = 3; dequeue = enqueueBackDequeue(dequeue, &value1); dequeue = enqueueBackDequeue(dequeue, &value2); dequeue = enqueueBackDequeue(dequeue, &value3); CU_ASSERT_EQUAL(3, sizeDequeue(dequeue)); int *position3 = (int *)dequeueBackDequeue(dequeue); int *position2 = (int *)dequeueBackDequeue(dequeue); int *position1 = (int *)dequeueBackDequeue(dequeue); CU_ASSERT_EQUAL(0, sizeDequeue(dequeue)); printf("\nPosition%d (back): %d\n", 3, *position3); printf("\nPosition%d (back): %d\n", 2, *position2); printf("\nPosition%d (back): %d\n", 1, *position1); CU_ASSERT_PTR_EQUAL(position3, &value3); CU_ASSERT_PTR_EQUAL(position2, &value2); CU_ASSERT_PTR_EQUAL(position1, &value1); }
static void test_queue(void) { struct ofp_ifqueue ifq; struct ifq_entry e; ifq.ifq_tail = NULL; ifq.ifq_len = 0; e.next = NULL; odp_packet_t m = odp_packet_alloc(ofp_packet_pool, 0); IF_ENQUEUE(&ifq, m) while (0); CU_ASSERT_PTR_NOT_NULL(ifq.ifq_head); CU_ASSERT_PTR_EQUAL(ifq.ifq_head, ifq.ifq_tail); CU_ASSERT_PTR_NULL(ifq.ifq_tail->next); CU_ASSERT_EQUAL(ifq.ifq_len, 1); ifq.ifq_head = ifq.ifq_tail = &e; IF_ENQUEUE(&ifq, m) while (0); CU_ASSERT_PTR_NOT_NULL(ifq.ifq_head); CU_ASSERT_PTR_NOT_NULL(ifq.ifq_tail); CU_ASSERT_PTR_NOT_EQUAL(ifq.ifq_head, ifq.ifq_tail); CU_ASSERT_PTR_EQUAL(ifq.ifq_head->next, ifq.ifq_tail); CU_ASSERT_PTR_NULL(ifq.ifq_tail->next); CU_ASSERT_EQUAL(ifq.ifq_len, 2); odp_packet_free(m); }
void case_cmd_expireat_invalid_param() { answer_t *ans; CU_ASSERT_EQUAL(kv_init(NULL), ERR_NONE); ans = kv_ask("expireat", strlen("expireat")); CU_ASSERT_EQUAL(ans->errnum, ERR_ARGUMENTS); CU_ASSERT_PTR_EQUAL(answer_value_to_string(answer_first_value(ans)), NULL); answer_release(ans); ans = kv_ask("expireat key", strlen("expireat key")); CU_ASSERT_EQUAL(ans->errnum, ERR_ARGUMENTS); CU_ASSERT_PTR_EQUAL(answer_value_to_string(answer_first_value(ans)), NULL); answer_release(ans); ans = kv_ask("expireat key 10 20", strlen("expireat key 10 20")); CU_ASSERT_EQUAL(ans->errnum, ERR_ARGUMENTS); CU_ASSERT_PTR_EQUAL(answer_value_to_string(answer_first_value(ans)), NULL); answer_release(ans); ans = kv_ask("expireat key 123456789012345678901234567890", strlen("expireat key 123456789012345678901234567890")); CU_ASSERT_EQUAL(ans->errnum, ERR_VALUE); CU_ASSERT_PTR_EQUAL(answer_value_to_string(answer_first_value(ans)), NULL); answer_release(ans); kv_uninit(); }
void ASSERT_LIST_EQUAL2(list_t *list, void *exp1, void *exp2) { CU_ASSERT_PTR_NOT_NULL(list->tail); CU_ASSERT_PTR_NOT_NULL(list->head); CU_ASSERT_PTR_EQUAL(list->head->payload,exp1); CU_ASSERT_PTR_EQUAL(list->tail->payload,exp2); CU_ASSERT_PTR_EQUAL(list->tail, list->head->next); CU_ASSERT_PTR_NULL(list->tail->next); }
void test_phalcon_cpy_wrt(void) { startup_php(__func__); zend_first_try { zval* dest; zval* src; PHALCON_MM_GROW(); /* dest is not observed by Phalcon */ MAKE_STD_ZVAL(dest); ZVAL_STRING(dest, "R^itaM cha svAdhyAyapravachane cha", 1); PHALCON_INIT_VAR(src); ZVAL_STRING(src, "satyaM cha svAdhyAyapravachane cha", 1); PHALCON_CPY_WRT(dest, src); CU_ASSERT_PTR_EQUAL(dest, src); CU_ASSERT_EQUAL(Z_REFCOUNT_P(src), 2); CU_ASSERT_EQUAL(Z_TYPE_P(src), IS_STRING); PHALCON_MM_RESTORE(); CU_ASSERT_EQUAL(_mem_block_check(dest, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1); CU_ASSERT_PTR_EQUAL(dest, src); CU_ASSERT_EQUAL(Z_REFCOUNT_P(dest), 1); CU_ASSERT_EQUAL(Z_TYPE_P(src), IS_STRING); CU_ASSERT_STRING_EQUAL(Z_STRVAL_P(src), "satyaM cha svAdhyAyapravachane cha"); zval_ptr_dtor(&dest); PHALCON_MM_GROW(); /* dest will be observed by Phalcon */ dest = NULL; PHALCON_INIT_VAR(src); ZVAL_STRING(src, "satyaM cha svAdhyAyapravachane cha", 1); PHALCON_CPY_WRT(dest, src); CU_ASSERT_PTR_EQUAL(dest, src); CU_ASSERT_EQUAL(Z_REFCOUNT_P(src), 2); CU_ASSERT_EQUAL(Z_TYPE_P(src), IS_STRING); PHALCON_MM_RESTORE(); /* At this point dest will be destroyed */ } zend_catch { CU_ASSERT(0); } zend_end_try(); shutdown_php(); CU_ASSERT_EQUAL(leaks, 0); }
void test_iterator_init_destroy(void) { list_t* list = list_init(); iterator_t* i=iterator_init(list); CU_ASSERT_PTR_NOT_NULL(i); CU_ASSERT_PTR_EQUAL(i->list, list); CU_ASSERT_PTR_EQUAL(i->currentNode, list->head); iterator_destroy(i); list_destroy(list); }
static void test_helper_strdup() { // Check for only one strdup. helper_strdup is only needed as long as strdup is not defined anyway. CU_ASSERT_PTR_EQUAL(strdup, helper_strdup); char* str = "a test string"; char* got = helper_strdup(str); CU_ASSERT_STRING_EQUAL(str, got); CU_ASSERT_PTR_NOT_EQUAL(str, got); free(got); // Test returning NULL CU_ASSERT_PTR_EQUAL(helper_strdup(NULL), NULL); }
void t_sendqueue2(void) { int result; result = coap_insert_node(&sendqueue, node[2]); CU_ASSERT(result > 0); CU_ASSERT_PTR_EQUAL(sendqueue, node[1]); CU_ASSERT_PTR_EQUAL(sendqueue->next, node[2]); CU_ASSERT(sendqueue->t == timestamp[1]); CU_ASSERT(node[2]->t == timestamp[2] - timestamp[1]); }
static void test_q_dequeue(void) { Queue* q = q_new(); int first; int status = q_enqueue(q, &first); int second; status = q_enqueue(q, &second); CU_ASSERT_PTR_EQUAL(q_dequeue(q), &first); CU_ASSERT_EQUAL(q_size(q), 1); CU_ASSERT_PTR_EQUAL(q_dequeue(q), &second); CU_ASSERT_EQUAL(q_size(q), 0); q_free(q); }
PRIVATE void test_loc_sector_end(void) { const struct flash_layout *l = &__test_layout; struct flash_loc loc= {0}; struct flash_loc s; loc.ly = l; loc.abs = 0x302010; loc.s = 0x30; loc.p = 0x20; loc.o = 0x10; CU_ASSERT_EQUAL( flash_loc__sector_end(&loc, &s), E_GOOD ); CU_ASSERT_EQUAL( loc.s, s.s ); CU_ASSERT_EQUAL( s.p, 0xFF ); CU_ASSERT_EQUAL( s.o, 0xFF ); CU_ASSERT_EQUAL( s.abs, 0x30FFFF ); CU_ASSERT_PTR_EQUAL( loc.ly, s.ly ); loc.abs = 0xF0FFFF; loc.s = 0xF0; loc.p = 0xFF; loc.o = 0xFF; CU_ASSERT_EQUAL( flash_loc__sector_end(&loc, &s), E_GOOD ); CU_ASSERT_EQUAL( loc.abs, s.abs ); CU_ASSERT_EQUAL( s.s, 0xF0 ); CU_ASSERT_EQUAL( s.p, 0xFF ); CU_ASSERT_EQUAL( s.o, 0xFF ); loc.s = 0x100; CU_ASSERT_NOT_EQUAL( flash_loc__sector_end(&loc, &s), E_GOOD ); }
void test_free_block_reallouable() { void* ptr = mymalloc(4); myfree(ptr); void* ptr2= mymalloc(4); CU_ASSERT_PTR_EQUAL(ptr, ptr2); myfree(ptr2); }
//Buffer e array hanno la stessa dimensione void ASSERT_BUFFER_EQUALS(buffer_t* buffer, msg_t* messages[]) { int i; for(i=0; i<buffer->size; i++) { CU_ASSERT_PTR_EQUAL(buffer->queue[buffer->T].content,messages[i]->content); buffer->T=(buffer->T+1)%(buffer->size); } }
void test_pointer_function_registry() { function_registry* fr = pointer_function_registry(); int* tester = (int*)&fr; /* start the tests */ printf("Test pointer_function_registry: "); CU_ASSERT_TRUE(!strcmp(fr->name, "pointer")); /* test the copy function */ void** cpy = (void**)fr->copy(&tester); CU_ASSERT_PTR_EQUAL(*cpy, tester); /* test to be sure that it is actually a copy */ tester = (int*)&tester; CU_ASSERT_PTR_NOT_EQUAL(*cpy, tester); /* free memory */ fr->destroy(cpy); free(fr); /* finish the test */ test_failure(); printf("\n"); }
void test_find_file(void) { FILENODE *node; FILENODE *keeper_node; GtkTreeIter iter; GtkTreeIter keeper_iter; init_file_list(); node = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); node = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); node = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); node = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); keeper_node = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &keeper_iter); CU_ASSERT_PTR_NOT_NULL(node); node = append_file("file6", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); node = append_file("file7", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); node = append_file("file8", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node); node = find_file_by_iter(&keeper_iter); CU_ASSERT_PTR_NOT_NULL(node); CU_ASSERT_PTR_EQUAL(node, keeper_node); destroy_file_list(); }
void test_traversal(void) { FILENODE *node[5]; FILENODE *current_node; GtkTreeIter iter; int i = 0; init_file_list(); node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[0]); node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[1]); node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[2]); node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[3]); node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[4]); current_node = get_next_node(NULL); CU_ASSERT_PTR_NOT_NULL(current_node); while (current_node != NULL) { CU_ASSERT_NOT_EQUAL(i, 5); CU_ASSERT_PTR_EQUAL(current_node, node[i]); current_node = get_next_node(current_node); i++; } }
void testNewSpecBin(void) { char *error = NULL; union { uint16_t num; char bytes[2]; } n16; n16.num = 5; n16.num = bswap16(n16.num); union { uint32_t num; char bytes[4]; } n32; n32.num = 5; n32.num = bswap32(n32.num); char buf[] = {'\x93', /* 10010011 */ '\xc4', (uint8_t)5, 'H', 'e', 'l', 'l', 'o', '\xc5', n16.bytes[0], n16.bytes[1], 'H', 'e', 'l', 'l', 'o', '\xc6', n32.bytes[0], n32.bytes[1], n32.bytes[2], n32.bytes[3], 'H', 'e', 'l', 'l', 'o', }; size_t n = sizeof(buf); CU_ASSERT_EQUAL(msgpackclen_buf_read (buf, n, &error), n); CU_ASSERT_PTR_EQUAL(error, NULL); if (error) free(error); }
void test_find_index(void) { FILENODE *node[5]; FILENODE *current_node; GtkTreeIter iter; int index[11] = {4, 3, 2, 1, 0, 3, 2, 4, 0, 1, 1}; int i = 0; init_file_list(); node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[0]); node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[1]); node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[2]); node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[3]); node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter); CU_ASSERT_PTR_NOT_NULL(node[4]); for (i = 0; i < 11; i++) { current_node = find_file_by_index(index[i]); CU_ASSERT_PTR_EQUAL(node[index[i]], current_node); } destroy_file_list(); }
void test_pop(void) { Stack s = NULL; Stack scomp; char* a = "sdfghjklm"; char* b = "azerty"; char* res; S_push(&s, a); scomp = s; S_push(&s, b); res = (char*)S_pop(&s); CU_ASSERT_STRING_EQUAL(res, b); CU_ASSERT_PTR_EQUAL(s, scomp); res = (char*)S_pop(&s); CU_ASSERT_STRING_EQUAL(res, a); CU_ASSERT_PTR_EQUAL(s, NULL); }
void case_cmd_expireat_stress() { int i; answer_t *ans; static char buf[10000+128]; kv_uninit(); kv_init(NULL); ans = kv_ask("set key value", strlen("set key value")); CU_ASSERT_EQUAL(ans->errnum, ERR_NONE); answer_release(ans); for (i = 10000; i >= 1; i--) { snprintf(buf, sizeof(buf), "expireat key %ld", time(NULL) + i); ans = kv_ask(buf, strlen(buf)); CU_ASSERT_STRING_EQUAL(answer_value_to_string(answer_first_value(ans)), "1"); answer_release(ans); } ans = kv_ask("get key", strlen("get key")); CU_ASSERT_EQUAL(ans->errnum, ERR_NONE); CU_ASSERT_STRING_EQUAL(answer_value_to_string(answer_first_value(ans)), "value"); answer_release(ans); sleep(2); ans = kv_ask("get key", strlen("get key")); CU_ASSERT_EQUAL(ans->errnum, ERR_NIL); CU_ASSERT_PTR_EQUAL(answer_value_to_string(answer_first_value(ans)), NULL); answer_release(ans); kv_uninit(); CU_ASSERT_EQUAL(kv_get_used_memory(), 0); }