summaryrefslogtreecommitdiffstats
path: root/test/btree2.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-02-24 21:44:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-02-24 21:44:30 (GMT)
commit2be0f58f6018d3ccf4e9929aa3f4cbd3c593624a (patch)
tree7330209dfa9939d178c1b69c0464f1e01b41ade8 /test/btree2.c
parentb1485cfdcff1963c15f98bea565f4737cb9ad397 (diff)
downloadhdf5-2be0f58f6018d3ccf4e9929aa3f4cbd3c593624a.zip
hdf5-2be0f58f6018d3ccf4e9929aa3f4cbd3c593624a.tar.gz
hdf5-2be0f58f6018d3ccf4e9929aa3f4cbd3c593624a.tar.bz2
[svn-r10078] Purpose:
Bug fix & new feature Description: Fix errors in tracking the total number of records "below" a node. Add feature to find the n'th record in a B-tree Platforms tested: FreeBSD 4.11 (sleipnir) Solaris 2.9 (shanti)
Diffstat (limited to 'test/btree2.c')
-rw-r--r--test/btree2.c101
1 files changed, 98 insertions, 3 deletions
diff --git a/test/btree2.c b/test/btree2.c
index 9ff7755..af0d8fe 100644
--- a/test/btree2.c
+++ b/test/btree2.c
@@ -164,6 +164,14 @@ test_insert_basic(hid_t fapl)
/* Should fail */
if(ret != FAIL) TEST_ERROR;
+ /* Attempt to index record in B-tree with no records */
+ idx = 0;
+ H5E_BEGIN_TRY {
+ ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)0, find_cb, NULL);
+ } H5E_END_TRY;
+ /* Should fail */
+ if(ret != FAIL) TEST_ERROR;
+
/*
* Test inserting record into v2 B-tree
*/
@@ -187,6 +195,18 @@ test_insert_basic(hid_t fapl)
idx = 42;
if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0) TEST_ERROR;
+ /* Attempt to index non-existant record in B-tree with 1 record */
+ idx = 0;
+ H5E_BEGIN_TRY {
+ ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)1, find_cb, NULL);
+ } H5E_END_TRY;
+ /* Should fail */
+ if(ret != FAIL) TEST_ERROR;
+
+ /* Attempt to index existing record in B-tree with 1 record */
+ idx = 42;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)0, find_cb, &idx)<0) TEST_ERROR;
+
/*
* Test inserting second record into v2 B-tree, before all other records
*/
@@ -229,6 +249,24 @@ test_insert_basic(hid_t fapl)
idx = 56;
if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0) TEST_ERROR;
+ /* Attempt to index non-existant record in B-tree with several records */
+ idx = 0;
+ H5E_BEGIN_TRY {
+ ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)4, find_cb, NULL);
+ } H5E_END_TRY;
+ /* Should fail */
+ if(ret != FAIL) TEST_ERROR;
+
+ /* Attempt to index existing record in B-tree with several records */
+ idx = 34;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)0, find_cb, &idx)<0) TEST_ERROR;
+ idx = 38;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)1, find_cb, &idx)<0) TEST_ERROR;
+ idx = 42;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)2, find_cb, &idx)<0) TEST_ERROR;
+ idx = 56;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)3, find_cb, &idx)<0) TEST_ERROR;
+
PASSED();
if (H5Fclose(file)<0) TEST_ERROR;
@@ -347,6 +385,26 @@ test_insert_split_root(hid_t fapl)
idx = 56;
if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0) TEST_ERROR;
+ /* Attempt to index non-existant record in level-1 B-tree */
+ idx = 0;
+ H5E_BEGIN_TRY {
+ ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)(INSERT_SPLIT_ROOT_NREC+2), find_cb, NULL);
+ } H5E_END_TRY;
+ /* Should fail */
+ if(ret != FAIL) TEST_ERROR;
+
+ /* Attempt to index existing record in root of level-1 B-tree */
+ idx = 33;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)33, find_cb, &idx)<0) TEST_ERROR;
+
+ /* Attempt to index existing record in left leaf of level-1 B-tree */
+ idx = 0;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)0, find_cb, &idx)<0) TEST_ERROR;
+
+ /* Attempt to index existing record in right leaf of level-1 B-tree */
+ idx = 50;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)50, find_cb, &idx)<0) TEST_ERROR;
+
PASSED();
if (H5Fclose(file)<0) TEST_ERROR;
@@ -930,6 +988,26 @@ test_insert_make_level2(hid_t fapl)
idx = 346;
if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0) TEST_ERROR;
+ /* Attempt to index non-existant record in level-1 B-tree */
+ idx = 0;
+ H5E_BEGIN_TRY {
+ ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)(INSERT_SPLIT_ROOT_NREC*12), find_cb, NULL);
+ } H5E_END_TRY;
+ /* Should fail */
+ if(ret != FAIL) TEST_ERROR;
+
+ /* Attempt to index existing record in root of level-2 B-tree */
+ idx = 433;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)433, find_cb, &idx)<0) TEST_ERROR;
+
+ /* Attempt to index existing record in internal node of level-2 B-tree */
+ idx = 734;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)734, find_cb, &idx)<0) TEST_ERROR;
+
+ /* Attempt to index existing record in leaf of level-2 B-tree */
+ idx = 883;
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)883, find_cb, &idx)<0) TEST_ERROR;
+
PASSED();
if (H5Fclose(file)<0) TEST_ERROR;
@@ -1720,7 +1798,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Make certain that the index is correct */
if(idx != INSERT_MANY) TEST_ERROR;
- /* Attempt to find non-existant record in level-1 B-tree */
+ /* Attempt to find non-existant record in level-4 B-tree */
idx = INSERT_MANY*2;
H5E_BEGIN_TRY {
ret = H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx);
@@ -1731,12 +1809,29 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
/* Find random records */
for(u=0; u<FIND_MANY; u++) {
/* Pick random record */
- idx = (unsigned)(HDrandom()%INSERT_MANY);
+ idx = (hsize_t)(HDrandom()%INSERT_MANY);
- /* Attempt to find existant record in root of level-2 B-tree */
+ /* Attempt to find existant record in root of level-4 B-tree */
if(H5B2_find(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, &idx, find_cb, &idx)<0) TEST_ERROR;
} /* end for */
+ /* Attempt to index non-existant record in level-4 B-tree */
+ idx = 0;
+ H5E_BEGIN_TRY {
+ ret = H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, (hsize_t)(INSERT_MANY*3), find_cb, NULL);
+ } H5E_END_TRY;
+ /* Should fail */
+ if(ret != FAIL) TEST_ERROR;
+
+ /* Find random records */
+ for(u=0; u<FIND_MANY; u++) {
+ /* Pick random record */
+ idx = (hsize_t)(HDrandom()%INSERT_MANY);
+
+ /* Attempt to find existant record in root of level-4 B-tree */
+ if(H5B2_index(f, H5P_DATASET_XFER_DEFAULT, H5B2_TEST, bt2_addr, idx, find_cb, &idx)<0) TEST_ERROR;
+ } /* end for */
+
PASSED();
if (H5Fclose(file)<0) TEST_ERROR;