X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/01021da3b27c6a5704bfa08cd0ce07be6b925e8b..0450dbf72458f8c636206f2e823edf31840c95fa:/testsuite/xbt/dynar_double.c diff --git a/testsuite/xbt/dynar_double.c b/testsuite/xbt/dynar_double.c index b09e78873c..bfd06410a7 100644 --- a/testsuite/xbt/dynar_double.c +++ b/testsuite/xbt/dynar_double.c @@ -2,128 +2,126 @@ /* dynar_double: A test case for the dynar using doubles as content */ -/* Authors: Martin Quinson */ -/* Copyright (C) 2003 the OURAGAN project. */ +/* Copyright (c) 2003,2004 Martin Quinson. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include +#include "gras.h" -GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test"); +XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test"); int main(int argc,char *argv[]) { - gras_dynar_t d; - gras_error_t errcode; + xbt_dynar_t d; + xbt_error_t errcode; int cpt,cursor; double d1,d2; - gras_init_defaultlog(&argc,argv,"dynar.thresh=debug"); + xbt_init_defaultlog(&argc,argv,"dynar.thresh=debug"); INFO0("==== Traverse the empty dynar"); - d=gras_dynar_new(sizeof(int),NULL); - gras_dynar_foreach(d,cursor,cpt){ - gras_assert0(FALSE, + d=xbt_dynar_new(sizeof(int),NULL); + xbt_dynar_foreach(d,cursor,cpt){ + xbt_assert0(FALSE, "Damnit, there is something in the empty dynar"); } - gras_dynar_free(&d); - gras_dynar_free(&d); + xbt_dynar_free(&d); + xbt_dynar_free(&d); INFO0("==== Push/shift 5000 doubles"); - d=gras_dynar_new(sizeof(double),NULL); + d=xbt_dynar_new(sizeof(double),NULL); for (cpt=0; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_push(d,&d1); + xbt_dynar_push(d,&d1); } - gras_dynar_foreach(d,cursor,d2){ + xbt_dynar_foreach(d,cursor,d2){ d1=(double)cursor; - gras_assert2(d1 == d2, + xbt_assert2(d1 == d2, "The retrieved value is not the same than the injected one (%f!=%f)", d1,d2); } for (cpt=0; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_shift(d,&d2); - gras_assert2(d1 == d2, + xbt_dynar_shift(d,&d2); + xbt_assert2(d1 == d2, "The retrieved value is not the same than the injected one (%f!=%f)", d1,d2); } - gras_dynar_free(&d); - gras_dynar_free(&d); + xbt_dynar_free(&d); + xbt_dynar_free(&d); INFO0("==== Unshift/pop 5000 doubles"); - d=gras_dynar_new(sizeof(double),NULL); + d=xbt_dynar_new(sizeof(double),NULL); for (cpt=0; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_unshift(d,&d1); + xbt_dynar_unshift(d,&d1); } for (cpt=0; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_pop(d,&d2); - gras_assert2 (d1 == d2, + xbt_dynar_pop(d,&d2); + xbt_assert2 (d1 == d2, "The retrieved value is not the same than the injected one (%f!=%f)", d1,d2); } - gras_dynar_free(&d); - gras_dynar_free(&d); + xbt_dynar_free(&d); + xbt_dynar_free(&d); INFO0("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything"); - d=gras_dynar_new(sizeof(double),NULL); + d=xbt_dynar_new(sizeof(double),NULL); for (cpt=0; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_push(d,&d1); + xbt_dynar_push(d,&d1); } for (cpt=0; cpt< 1000; cpt++) { d1=(double)cpt; - gras_dynar_insert_at(d,2500,&d1); + xbt_dynar_insert_at(d,2500,&d1); } for (cpt=0; cpt< 2500; cpt++) { d1=(double)cpt; - gras_dynar_shift(d,&d2); - gras_assert2(d1 == d2, + xbt_dynar_shift(d,&d2); + xbt_assert2(d1 == d2, "The retrieved value is not the same than the injected one at the begining (%f!=%f)", d1,d2); - DEBUG2("Pop %d, length=%lu",cpt, gras_dynar_length(d)); + DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d)); } for (cpt=999; cpt>=0; cpt--) { d1=(double)cpt; - gras_dynar_shift(d,&d2); - gras_assert2 (d1 == d2, + xbt_dynar_shift(d,&d2); + xbt_assert2 (d1 == d2, "The retrieved value is not the same than the injected one in the middle (%f!=%f)", d1,d2); } for (cpt=2500; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_shift(d,&d2); - gras_assert2 (d1 == d2, + xbt_dynar_shift(d,&d2); + xbt_assert2 (d1 == d2, "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); + xbt_dynar_free(&d); + xbt_dynar_free(&d); INFO0("==== Push 5000 double, remove 2000-4000. free the rest"); - d=gras_dynar_new(sizeof(double),NULL); + d=xbt_dynar_new(sizeof(double),NULL); for (cpt=0; cpt< 5000; cpt++) { d1=(double)cpt; - gras_dynar_push(d,&d1); + xbt_dynar_push(d,&d1); } for (cpt=2000; cpt< 4000; cpt++) { d1=(double)cpt; - gras_dynar_remove_at(d,2000,&d2); - gras_assert2 (d1 == d2, + xbt_dynar_remove_at(d,2000,&d2); + xbt_assert2 (d1 == d2, "Remove a bad value. Got %f, expected %f", d2,d1); } - gras_dynar_free(&d); - gras_dynar_free(&d); + xbt_dynar_free(&d); + xbt_dynar_free(&d); - gras_exit(); + xbt_exit(); return 0; }