Ejemplo n.º 1
0
char *test_remove() {
    int *val_check = DArray_remove(array, 0);
    mu_assert(val_check != NULL, "Should not get NULL");
    mu_assert(*val_check == *val1, "Should get the first value");
    mu_assert(DArray_get(array,0) == NULL, "Should be gone.");
    DArray_free(val_check);

    val_check = DArray_remove(array, 1);
    mu_assert(val_check != NULL, "Should not get NULL");
    mu_assert(*val_check == *val2, "Should get the second value");
    mu_assert(DArray_get(array,1) == NULL, "Should be gone.");
    DArray_free(val_check);
    
    return NULL;
}
Ejemplo n.º 2
0
char *test_push_pop() {
    int i = 0;
    for(i=0; i<1000; i++) {
        int *val = DArray_new(array);
        *val = i*333;
        DArray_push(array, val);
    }

    mu_assert(array->max == 1201, "Wrong max size");

    for(i=999; i>=0; i--) {
        int *val = DArray_pop(array);
        mu_assert(val != NULL, "Should not be NULL");
        mu_assert(*val == i*333, "Wrong value");
        DArray_free(val);
    }

    return NULL;
}
char *test_push_pop()
{
	int i = 0;
	for (i = 0; i < 1000; i++) {
		int *val = DArray_new(array);
		*val = i * 333;
		DArray_push(array, val);
		//int valuepushed = *( (int*)DArray_get(array, i));
		//printf("%d", valuepushed);
		//debug("%d: At address %x, we have %d",i, DArray_get(array, i), 
	//			*((int*)DArray_get(array, i)) );
	}

	mu_assert(array->max == 1201, "Wrong max size.");

	for (i = 999; i >= 0; i--) {
		int *val = DArray_pop(array);
		mu_assert(val != NULL, "Shouldn't get a NULL");
		mu_assert(*val == i * 333, "Wrong Value.");
		DArray_free(val);
	}
	return NULL;

}