diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-02-06 16:08:29 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-02-06 16:08:29 (GMT) |
commit | c6bd03047bda62861529e1615099cd7e472cdbac (patch) | |
tree | 348d313abdad3ce689445be186d376d8fd0b90cd /test/tgenprop.c | |
parent | eb5697d309462919f3f00ec16c16bea7d0d66432 (diff) | |
download | hdf5-c6bd03047bda62861529e1615099cd7e472cdbac.zip hdf5-c6bd03047bda62861529e1615099cd7e472cdbac.tar.gz hdf5-c6bd03047bda62861529e1615099cd7e472cdbac.tar.bz2 |
[svn-r4905] Purpose:
Regression tests
Description:
Generic property classes derived from an existing class were not having
the parent class's properties copied into the new class.
Additionally, derived classes were not being detected correctly.
Solution:
Added regression tests to verify that these fixes are working:
Copied properties from parent class into derived class.
Modified H5P_isa_class_real() to walk back up the chain of parent
classes to proper detect derived classes.
Platforms tested:
FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'test/tgenprop.c')
-rw-r--r-- | test/tgenprop.c | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/test/tgenprop.c b/test/tgenprop.c index 163ccf7..71ab27a 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -22,6 +22,7 @@ #include "testhdf5.h" #include "hdf5.h" +#include "H5Dprivate.h" /* For Datset creation property list names */ #define FILENAME "tgenprop.h5" @@ -1202,6 +1203,170 @@ test_genprop_list_callback(void) /**************************************************************** ** +** test_genprop_list_addprop(): Test adding properties to a +** standard HDF5 property list and verify that the library +** ignores the extra properties. +** +****************************************************************/ +static void +test_genprop_list_addprop(void) +{ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t pid; /* Property List ID */ + int prop1_value; /* Value for property #1 */ + herr_t ret; /* Generic return value */ + + /* Create file */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create scalar dataspace for dataset */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a dataset creation property list */ + pid = H5Pcreate(H5P_DATASET_CREATE); + CHECK(pid, FAIL, "H5Pcreate"); + + /* Insert temporary property into class (with no callbacks) */ + ret = H5Pinsert(pid,PROP1_NAME,PROP1_SIZE,PROP1_DEF_VALUE,NULL,NULL,NULL,NULL,NULL); + CHECK_I(ret, "H5Pinsert"); + + /* Check existence of added property */ + ret = H5Pexist(pid,PROP1_NAME); + VERIFY(ret, 1, "H5Pexist"); + + /* Check values of property (set with default value) */ + ret = H5Pget(pid,PROP1_NAME,&prop1_value); + CHECK_I(ret, "H5Pget"); + VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); + + /* Create a dataset */ + did=H5Dcreate(fid,"Dataset1",H5T_NATIVE_INT,sid,pid); + CHECK(did, FAIL, "H5Dcreate"); + + /* Check existence of added property (after using property list) */ + ret = H5Pexist(pid,PROP1_NAME); + VERIFY(ret, 1, "H5Pexist"); + + /* Check values of property (set with default value) (after using property list) */ + ret = H5Pget(pid,PROP1_NAME,&prop1_value); + CHECK_I(ret, "H5Pget"); + VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); + + /* Close property list */ + ret = H5Pclose(pid); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close disk dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close Dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + +} /* end test_genprop_list_addprop() */ + +/**************************************************************** +** +** test_genprop_class_addprop(): Test adding properties to a +** standard HDF5 property class and verify that the library +** ignores the extra properties and continues to recognize the +** derived class as a valid version of the derived-from class. +** +****************************************************************/ +static void +test_genprop_class_addprop(void) +{ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t cid; /* Property Class ID */ + hid_t pid; /* Property List ID */ + int prop1_value; /* Value for property #1 */ + herr_t ret; /* Generic return value */ + + /* Create file */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create scalar dataspace for dataset */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a new class, dervied from the dataset creation property list class */ + cid = H5Pcreate_class(H5P_DATASET_CREATE,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL); + CHECK_I(cid, "H5Pcreate_class"); + + /* Check existence of an original property */ + ret = H5Pexist(cid,H5D_CRT_DATA_PIPELINE_NAME); + VERIFY(ret, 1, "H5Pexist"); + + /* Insert first property into class (with no callbacks) */ + ret = H5Pregister(cid,PROP1_NAME,PROP1_SIZE,PROP1_DEF_VALUE,NULL,NULL,NULL,NULL,NULL,NULL); + CHECK_I(ret, "H5Pregister"); + + /* Create a derived dataset creation property list */ + pid = H5Pcreate(cid); + CHECK(pid, FAIL, "H5Pcreate"); + + /* Check existence of an original property */ + ret = H5Pexist(pid,H5D_CRT_DATA_PIPELINE_NAME); + VERIFY(ret, 1, "H5Pexist"); + + /* Check existence of added property */ + ret = H5Pexist(pid,PROP1_NAME); + VERIFY(ret, 1, "H5Pexist"); + + /* Check values of property (set with default value) */ + ret = H5Pget(pid,PROP1_NAME,&prop1_value); + CHECK_I(ret, "H5Pget"); + VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); + + /* Create a dataset */ + did=H5Dcreate(fid,"Dataset1",H5T_NATIVE_INT,sid,pid); + CHECK(did, FAIL, "H5Dcreate"); + + /* Check existence of added property (after using property list) */ + ret = H5Pexist(pid,PROP1_NAME); + VERIFY(ret, 1, "H5Pexist"); + + /* Check values of property (set with default value) (after using property list) */ + ret = H5Pget(pid,PROP1_NAME,&prop1_value); + CHECK_I(ret, "H5Pget"); + VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); + + /* Close property class */ + ret = H5Pclose_class(cid); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close property list */ + ret = H5Pclose(pid); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close disk dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close Dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + +} /* end test_genprop_class_addprop() */ + +/**************************************************************** +** ** test_genprop(): Main generic property testing routine. ** ****************************************************************/ @@ -1222,6 +1387,9 @@ test_genprop(void) test_genprop_list_iter(); /* Test basic code for iterating over properties in a generic property list */ test_genprop_list_callback(); /* Test code for property list callbacks */ + test_genprop_list_addprop(); /* Test adding properties to HDF5 property list */ + test_genprop_class_addprop(); /* Test adding properties to HDF5 property class */ + } /* test_genprop() */ |