summaryrefslogtreecommitdiffstats
path: root/test/tskiplist.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-10-07 13:32:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-10-07 13:32:32 (GMT)
commitbdbdbb9f89db8d3a76fc71705cdbbd89124f4687 (patch)
tree53d16d2097c591d2c7094da6b8e2b23ef5663a0f /test/tskiplist.c
parentb256db872d5ce4f81c6486b60c4e29e8122b67c2 (diff)
downloadhdf5-bdbdbb9f89db8d3a76fc71705cdbbd89124f4687.zip
hdf5-bdbdbb9f89db8d3a76fc71705cdbbd89124f4687.tar.gz
hdf5-bdbdbb9f89db8d3a76fc71705cdbbd89124f4687.tar.bz2
[svn-r15801] Description:
Bring r15800 back from trunk: - File free space branch changes through r15794 Tested on: Mac OS X/32 10.5.5 (amazon) in debug mode Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'test/tskiplist.c')
-rw-r--r--test/tskiplist.c162
1 files changed, 161 insertions, 1 deletions
diff --git a/test/tskiplist.c b/test/tskiplist.c
index 6f56c39..289df0b 100644
--- a/test/tskiplist.c
+++ b/test/tskiplist.c
@@ -1165,6 +1165,164 @@ test_skiplist_greater(void)
/****************************************************************
**
+** test_skiplist_below(): Test H5SL (skip list) code.
+** Tests 'below' operation in skip lists.
+**
+****************************************************************/
+static void
+test_skiplist_below(void)
+{
+ H5SL_t *slist; /* Skip list created */
+ H5SL_node_t *node; /* Skip list node */
+ size_t u; /* Local index variable */
+ unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
+ /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
+ unsigned *found_item; /* Item found in skip list */
+ unsigned find_item; /* Item to add to skip list */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(7, ("Testing Skip List 'Less' Operation\n"));
+
+ /* Create a skip list */
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ CHECK(slist, NULL, "H5SL_create");
+
+ /* Insert objects into the skip list */
+ for(u = 0; u < 10; u++) {
+ ret = H5SL_insert(slist, &data[u], &data[u]);
+ CHECK(ret, FAIL, "H5SL_insert");
+ } /* end for */
+
+ /* Check for exact match of items in various positions */
+ find_item = 20;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_below");
+ find_item = 90;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_below");
+ find_item = 5;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_below");
+
+ /* Find item less than a missing key, in various positions */
+ find_item = 19;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 15, "H5SL_below");
+ find_item = 89;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 80, "H5SL_below");
+ find_item = 100;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 90, "H5SL_below");
+ find_item = 9;
+ node = H5SL_below(slist, &find_item);
+ CHECK(node, NULL, "H5SL_below");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 5, "H5SL_below");
+ find_item = 4;
+ node = H5SL_less(slist, &find_item);
+ VERIFY(node, NULL, "H5SL_below");
+
+ /* Close the skip list */
+ ret = H5SL_close(slist);
+ CHECK(ret, FAIL, "H5SL_close");
+
+} /* end test_skiplist_below() */
+
+/****************************************************************
+**
+** test_skiplist_above(): Test H5SL (skip list) code.
+** Tests 'above' operation in skip lists.
+**
+****************************************************************/
+static void
+test_skiplist_above(void)
+{
+ H5SL_t *slist; /* Skip list created */
+ H5SL_node_t *node; /* Skip list node */
+ size_t u; /* Local index variable */
+ unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90};
+ /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */
+ unsigned *found_item; /* Item found in skip list */
+ unsigned find_item; /* Item to add to skip list */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(7, ("Testing Skip List 'Greater' Operation\n"));
+
+ /* Create a skip list */
+ slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16);
+ CHECK(slist, NULL, "H5SL_create");
+
+ /* Insert objects into the skip list */
+ for(u = 0; u < 10; u++) {
+ ret = H5SL_insert(slist, &data[u], &data[u]);
+ CHECK(ret, FAIL, "H5SL_insert");
+ } /* end for */
+
+ /* Check for exact match of items in various positions */
+ find_item = 20;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_above");
+ find_item = 90;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_above");
+ find_item = 5;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, find_item, "H5SL_above");
+
+ /* Find item greater than a missing key, in various positions */
+ find_item = 19;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 20, "H5SL_above");
+ find_item = 89;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 90, "H5SL_above");
+ find_item = 100;
+ node = H5SL_above(slist, &find_item);
+ VERIFY(node, NULL, "H5SL_above");
+ find_item = 6;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 10, "H5SL_above");
+ find_item = 4;
+ node = H5SL_above(slist, &find_item);
+ CHECK(node, NULL, "H5SL_above");
+ found_item = H5SL_item(node);
+ VERIFY(*found_item, 5, "H5SL_above");
+
+ /* Close the skip list */
+ ret = H5SL_close(slist);
+ CHECK(ret, FAIL, "H5SL_close");
+
+} /* end test_skiplist_above() */
+
+/****************************************************************
+**
** test_skiplist_remote_first(): Test H5SL (skip list) code.
** Tests 'remove first' operation in skip lists.
**
@@ -1240,7 +1398,9 @@ test_skiplist(void)
test_skiplist_free(); /* Test 'free' operation */
test_skiplist_less(); /* Test 'less' operation */
test_skiplist_greater(); /* Test 'greater' operation */
- test_skiplist_remove_first(); /* Test 'remove first' operation */
+ test_skiplist_below(); /* Test 'below' operation */
+ test_skiplist_above(); /* Test 'above' operation */
+ test_skiplist_remove_first(); /* Test 'remove first' operation */
} /* end test_skiplist() */