GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
int main(int argc,char *argv[]) {
- gras_dynar_t *d;
+ gras_dynar_t d;
gras_error_t errcode;
int cpt,cursor;
double d1,d2;
gras_init_defaultlog(&argc,argv,"dynar.thresh=debug");
INFO0("==== Traverse the empty dynar");
- TRYFAIL(gras_dynar_new(&d,sizeof(int),NULL));
+ d=gras_dynar_new(sizeof(int),NULL);
gras_dynar_foreach(d,cursor,cpt){
gras_assert0(FALSE,
"Damnit, there is something in the empty dynar");
}
- gras_dynar_free(d);
+ gras_dynar_free(&d);
+ gras_dynar_free(&d);
INFO0("==== Push/shift 5000 doubles");
- TRYFAIL(gras_dynar_new(&d,sizeof(double),NULL));
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
- TRYFAIL(gras_dynar_push(d,&d1));
+ gras_dynar_push(d,&d1);
}
gras_dynar_foreach(d,cursor,d2){
d1=(double)cursor;
"The retrieved value is not the same than the injected one (%f!=%f)",
d1,d2);
}
- gras_dynar_free(d);
+ gras_dynar_free(&d);
+ gras_dynar_free(&d);
INFO0("==== Unshift/pop 5000 doubles");
- TRYFAIL(gras_dynar_new(&d,sizeof(double),NULL));
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
- TRYFAIL(gras_dynar_unshift(d,&d1));
+ gras_dynar_unshift(d,&d1);
}
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
"The retrieved value is not the same than the injected one (%f!=%f)",
d1,d2);
}
- gras_dynar_free(d);
+ gras_dynar_free(&d);
+ gras_dynar_free(&d);
INFO0("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
- TRYFAIL(gras_dynar_new(&d,sizeof(double),NULL));
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
- TRYFAIL(gras_dynar_push(d,&d1));
+ gras_dynar_push(d,&d1);
}
for (cpt=0; cpt< 1000; cpt++) {
d1=(double)cpt;
- TRYFAIL(gras_dynar_insert_at(d,2500,&d1));
+ gras_dynar_insert_at(d,2500,&d1);
}
for (cpt=0; cpt< 2500; cpt++) {
"The retrieved value is not the same than the injected one at the end (%f!=%f)",
d1,d2);
}
- gras_dynar_free(d);
+ gras_dynar_free(&d);
+ gras_dynar_free(&d);
INFO0("==== Push 5000 double, remove 2000-4000. free the rest");
- TRYFAIL(gras_dynar_new(&d,sizeof(double),NULL));
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
- TRYFAIL(gras_dynar_push(d,&d1));
+ gras_dynar_push(d,&d1);
}
for (cpt=2000; cpt< 4000; cpt++) {
d1=(double)cpt;
"Remove a bad value. Got %f, expected %f",
d2,d1);
}
- gras_dynar_free(d);
+ gras_dynar_free(&d);
+ gras_dynar_free(&d);
gras_exit();
return 0;