summaryrefslogtreecommitdiffstats
path: root/test/tgenprop.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tgenprop.c')
-rw-r--r--test/tgenprop.c141
1 files changed, 137 insertions, 4 deletions
diff --git a/test/tgenprop.c b/test/tgenprop.c
index 433b070..e8e36cb 100644
--- a/test/tgenprop.c
+++ b/test/tgenprop.c
@@ -30,9 +30,29 @@ static char RcsId[] = "$Revision$";
#define FILENAME "tgenprop.h5"
+/* Property definitions */
#define CLASS1_NAME "Class 1"
#define CLASS1_HASHSIZE 25
+#define CLASS2_NAME "Class 2"
+#define CLASS2_HASHSIZE 25
+
+/* Property definitions */
+#define PROP1_NAME "Property 1"
+int prop1_def=10; /* Property 1 default value */
+#define PROP1_SIZE sizeof(prop1_def)
+#define PROP1_DEF_VALUE (&prop1_def)
+
+#define PROP2_NAME "Property 2"
+float prop2_def=3.14; /* Property 2 default value */
+#define PROP2_SIZE sizeof(prop2_def)
+#define PROP2_DEF_VALUE (&prop2_def)
+
+#define PROP3_NAME "Property 3"
+char prop3_def[10]="Ten chars"; /* Property 3 default value */
+#define PROP3_SIZE sizeof(prop3_def)
+#define PROP3_DEF_VALUE (&prop3_def)
+
/****************************************************************
**
** test_genprop_basic_class(): Test basic generic property list code.
@@ -84,16 +104,16 @@ test_genprop_basic_class(void)
ret = H5Pclose_class(cid1);
CHECK_I(ret, "H5Pclose_class");
- /* Create a new generic class, derived from file creation class */
- cid1 = H5Pcreate_class(H5P_FILE_CREATE_NEW,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL);
+ /* Create another new generic class, derived from file creation class */
+ cid1 = H5Pcreate_class(H5P_FILE_CREATE_NEW,CLASS2_NAME,CLASS2_HASHSIZE,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Check class name */
name = H5Pget_class_name(cid1);
CHECK_PTR(name, "H5Pget_class_name");
- if(HDstrcmp(name,CLASS1_NAME)!=0) {
+ if(HDstrcmp(name,CLASS2_NAME)!=0) {
num_errs++;
- printf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME);
+ printf("Class names don't match!, name=%s, CLASS2_NAME=%s\n",name,CLASS2_NAME);
} /* end if */
free(name);
@@ -128,6 +148,118 @@ test_genprop_basic_class(void)
/****************************************************************
**
+** test_genprop_basic_class_prop(): Test basic generic property list code.
+** Tests adding properties to generic classes.
+**
+****************************************************************/
+static void
+test_genprop_basic_class_prop(void)
+{
+ hid_t cid1; /* Generic Property class ID */
+ size_t size; /* Size of property */
+ size_t nprops; /* Number of properties in class */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Basic Generic Property List Class Properties Functionality\n"));
+
+ /* Create a new generic class, derived from the root of the class hierarchy */
+ cid1 = H5Pcreate_class(H5P_NO_CLASS_NEW,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL);
+ CHECK_I(cid1, "H5Pcreate_class");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 0, "H5Pget_nprops");
+
+ /* Insert first property into class (with no callbacks) */
+ ret = H5Pregister(cid1,PROP1_NAME,PROP1_SIZE,PROP1_DEF_VALUE,NULL,NULL,NULL,NULL);
+ CHECK_I(ret, "H5Pregister");
+
+ /* Try to insert the first property again (should fail) */
+ ret = H5Pregister(cid1,PROP1_NAME,PROP1_SIZE,PROP1_DEF_VALUE,NULL,NULL,NULL,NULL);
+ VERIFY(ret, FAIL, "H5Pregister");
+
+ /* Check the size of the first property */
+ ret = H5Pget_size(cid1,PROP1_NAME,&size);
+ CHECK_I(ret, "H5Pget_size");
+ VERIFY(size, PROP1_SIZE, "H5Pget_size");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 1, "H5Pget_nprops");
+
+ /* Insert second property into class (with no callbacks) */
+ ret = H5Pregister(cid1,PROP2_NAME,PROP2_SIZE,PROP2_DEF_VALUE,NULL,NULL,NULL,NULL);
+ CHECK_I(ret, "H5Pregister");
+
+ /* Try to insert the second property again (should fail) */
+ ret = H5Pregister(cid1,PROP2_NAME,PROP2_SIZE,PROP2_DEF_VALUE,NULL,NULL,NULL,NULL);
+ VERIFY(ret, FAIL, "H5Pregister");
+
+ /* Check the size of the second property */
+ ret = H5Pget_size(cid1,PROP2_NAME,&size);
+ CHECK_I(ret, "H5Pget_size");
+ VERIFY(size, PROP2_SIZE, "H5Pget_size");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 2, "H5Pget_nprops");
+
+ /* Insert third property into class (with no callbacks) */
+ ret = H5Pregister(cid1,PROP3_NAME,PROP3_SIZE,PROP3_DEF_VALUE,NULL,NULL,NULL,NULL);
+ CHECK_I(ret, "H5Pregister");
+
+ /* Check the size of the third property */
+ ret = H5Pget_size(cid1,PROP3_NAME,&size);
+ CHECK_I(ret, "H5Pget_size");
+ VERIFY(size, PROP3_SIZE, "H5Pget_size");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 3, "H5Pget_nprops");
+
+ /* Unregister first property */
+ ret = H5Punregister(cid1,PROP1_NAME);
+ CHECK_I(ret, "H5Punregister");
+
+ /* Try to check the size of the first property (should fail) */
+ ret = H5Pget_size(cid1,PROP1_NAME,&size);
+ VERIFY(ret, FAIL, "H5Pget_size");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 2, "H5Pget_nprops");
+
+ /* Unregister second property */
+ ret = H5Punregister(cid1,PROP2_NAME);
+ CHECK_I(ret, "H5Punregister");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 1, "H5Pget_nprops");
+
+ /* Unregister third property */
+ ret = H5Punregister(cid1,PROP3_NAME);
+ CHECK_I(ret, "H5Punregister");
+
+ /* Check the number of properties in class */
+ ret = H5Pget_nprops(cid1,&nprops);
+ CHECK_I(ret, "H5Pget_nprops");
+ VERIFY(nprops, 0, "H5Pget_nprops");
+
+ /* Close class */
+ ret = H5Pclose_class(cid1);
+ CHECK_I(ret, "H5Pclose_class");
+} /* end test_genprop_basic_class_prop() */
+
+/****************************************************************
+**
** test_genprop(): Main generic property testing routine.
**
****************************************************************/
@@ -139,6 +271,7 @@ test_genprop(void)
/* These tests use the same file... */
test_genprop_basic_class(); /* Test basic code for creating a generic class */
+ test_genprop_basic_class_prop(); /* Test basic code for adding properties to a generic class */
} /* test_genprop() */