/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Test HDF Heap routines. REMARKS DESIGN BUGS/LIMITATIONS EXPORTED ROUTINES AUTHOR Quincey Koziol MODIFICATION HISTORY 2/18/03 - Started coding */ #include #include #include "testhdf5.h" #include "H5HPprivate.h" /* The number of elements in testing arrays */ #define NUM_ELEMS 1000 /* Objects for testing in heaps */ typedef struct test_obj { H5HP_info_t heap_info; /* Information required for heap. _MUST_ be first */ int val; /* Actual information for object */ } test_obj; /* Array of random element values */ static test_obj rand_num[NUM_ELEMS]; /* Array of random elements values, sorted in increasing order */ static test_obj inc_sort_num[NUM_ELEMS]; /* Array of random elements values, sorted in decreasing order */ static test_obj dec_sort_num[NUM_ELEMS]; static int tst_dec_sort(const void *_i1, const void *_i2) { const test_obj *i1=(const test_obj *)_i1; const test_obj *i2=(const test_obj *)_i2; if(i1->valval) return(1); else if(i1->val>i2->val) return(-1); return(0); } static int tst_inc_sort(const void *_i1, const void *_i2) { const test_obj *i1=(const test_obj *)_i1; const test_obj *i2=(const test_obj *)_i2; if(i1->valval) return(-1); else if(i1->val>i2->val) return(1); return(0); } /**************************************************************** ** ** test_heap_init(): Test H5HP (heap) code. ** Initialize data for Heap testing ** ****************************************************************/ static void test_heap_init(void) { time_t curr_time; /* Current time, for seeding random number generator */ size_t u; /* Local index variables */ /* Create randomized set of numbers */ curr_time=time(NULL); HDsrandom((unsigned)curr_time); for(u=0; uval, "H5HP_remove"); /* Check that the value is correct, based on the heap type */ if(heap_type==H5HP_MAX_HEAP) { if(val>last_val) TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); } /* end if */ else { if(valval, "H5HP_remove"); /* Check that the value is correct, based on the heap type */ if(heap_type==H5HP_MAX_HEAP) { if(val>last_val) TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); } /* end if */ else { if(val