summaryrefslogtreecommitdiffstats
path: root/test/fillval.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-06-05 15:40:36 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-06-05 15:40:36 (GMT)
commitda929510d630ae3ba14e1c088debd4e5726b200f (patch)
treeea0d4153d26ae500ae0ef180adf549ce083b6374 /test/fillval.c
parentc72914018e247321c06ff167e5ff0e46a3b41553 (diff)
downloadhdf5-da929510d630ae3ba14e1c088debd4e5726b200f.zip
hdf5-da929510d630ae3ba14e1c088debd4e5726b200f.tar.gz
hdf5-da929510d630ae3ba14e1c088debd4e5726b200f.tar.bz2
[svn-r13835] Description:
Incremental step forward in fixing problems with fill values that have a variable-length datatype. This set of changes fixes problems with the copying the property list values. Tested On: Mac OS X/32 10.4.9 (amazon) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'test/fillval.c')
-rw-r--r--test/fillval.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/test/fillval.c b/test/fillval.c
index 13f1d2e..2a63f4b 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -217,6 +217,100 @@ test_getset(void)
/*-------------------------------------------------------------------------
+ * Function: test_getset_vl
+ *
+ * Purpose: Tests the H5Pget_fill_value() and H5Pset_fill_value()
+ * functions, using variable-length datatype.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, May 31, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_getset_vl(hid_t fapl)
+{
+ hsize_t dims[1] = {2};
+ hid_t fileid = (-1), spaceid = (-1), typeid = (-1), datasetid = (-1), plistid = (-1);
+ char fill_value[] = "aaaa";
+ char orig_fill_value[] = "aaaa";
+ char *f1 = fill_value;
+ char *f2;
+ char filename[1024];
+
+ TESTING("property lists, with variable-length datatype");
+
+ /* Create string type. */
+ if((typeid = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
+ if(H5Tset_size(typeid, H5T_VARIABLE) < 0) TEST_ERROR
+
+ /* Set up dataset creation property list, with fill value */
+ if((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_fill_value(plistid, typeid, &f1) < 0) TEST_ERROR
+
+ /* Modify original fill value string */
+ fill_value[0] = 'b';
+
+ /* Retrieve fill value from property */
+ if(H5Pget_fill_value(plistid, typeid, &f2) < 0) TEST_ERROR
+
+ /* Verify that the fill value is the original value */
+ if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR
+
+ /* Release the fill value retrieved */
+ HDfree(f2);
+
+ /* Open file. */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Write an dataset of this type. */
+ if((spaceid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR
+ if((datasetid = H5Dcreate(fileid, "Dataset", typeid, spaceid, plistid)) < 0) TEST_ERROR
+
+ /* Close IDs (except datatype) */
+ if(H5Dclose(datasetid) < 0) TEST_ERROR
+ if(H5Pclose(plistid) < 0) TEST_ERROR
+ if(H5Sclose(spaceid) < 0) TEST_ERROR
+ if(H5Fclose(fileid) < 0) TEST_ERROR
+
+
+ /* Re-open file, group & dataset */
+ if((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((datasetid = H5Dopen(fileid, "Dataset")) < 0) TEST_ERROR
+
+ /* Get dataset's creation property list */
+ if((plistid = H5Dget_create_plist(datasetid)) < 0) TEST_ERROR
+
+ /* Query fill value */
+ if(H5Pget_fill_value(plistid, typeid, &f2) < 0) TEST_ERROR
+
+ /* Verify that the fill value is the original value */
+ if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR
+
+ /* Release the fill value retrieved */
+ HDfree(f2);
+
+ /* Close IDs */
+ if(H5Dclose(datasetid) < 0) TEST_ERROR
+ if(H5Fclose(fileid) < 0) TEST_ERROR
+ if(H5Pclose(plistid) < 0) TEST_ERROR
+ if(H5Tclose(typeid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ } H5E_END_TRY;
+ return 1;
+} /* end test_getset_vl() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_create
*
* Purpose: Tests creating datasets that have fill values.
@@ -1433,6 +1527,7 @@ main(int argc, char *argv[])
fapl = h5_fileaccess();
nerrors += test_getset();
+ nerrors += test_getset_vl(fapl);
/* Chunked storage layout tests */
if (test_chunk) {