summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2004-10-01 19:42:21 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2004-10-01 19:42:21 (GMT)
commit8231b5f0c94aa6680ad8c8b980e1352f1d50f626 (patch)
tree4bed76ea2b9b3f17e00ce4991e10b66aa16bf21d /test
parent08be85a294f76b57d338fdd46c9224039b0e05f3 (diff)
downloadhdf5-8231b5f0c94aa6680ad8c8b980e1352f1d50f626.zip
hdf5-8231b5f0c94aa6680ad8c8b980e1352f1d50f626.tar.gz
hdf5-8231b5f0c94aa6680ad8c8b980e1352f1d50f626.tar.bz2
[svn-r9351]
Purpose: enhanced feature Description: enable size adjustment for compound datatype. The size can be increased and decreased(as long as the members are not cut). Solution: mainly check if any member is being cut when decreasing the size. Others are simply taking out the assertion against 0 size. Platforms tested: h5committest and fuss. Misc. update: RELEASE.txt
Diffstat (limited to 'test')
-rw-r--r--test/dtypes.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 00001f3..83e41ad 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -2034,6 +2034,77 @@ test_compound_11(void)
/*-------------------------------------------------------------------------
+ * Function: test_compound_12
+ *
+ * Purpose: Tests size adjustment of compound data types. Start with
+ * no member and 0 size, increase the size as inserting
+ * members.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Raymond Lu
+ * Wednesday, September 29, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_12(void)
+{
+ complex_t tmp;
+ hid_t complex_id;
+ size_t size = 0;
+ size_t offset, new_size;
+ herr_t ret;
+
+ TESTING("adjust size of compound data types");
+
+ /* Create the empty compound type */
+ if ((complex_id = H5Tcreate(H5T_COMPOUND, 0))<0) goto error;
+
+ /* Add a couple fields and adjust the size */
+ offset = size;
+ if((size+=H5Tget_size(H5T_NATIVE_DOUBLE))<0) goto error;
+ if (H5Tset_size(complex_id, size)<0) goto error;
+ if (H5Tinsert(complex_id, "real", offset,
+ H5T_NATIVE_DOUBLE)<0) goto error;
+
+ offset = size;
+ if((size+=H5Tget_size(H5T_NATIVE_DOUBLE))<0) goto error;
+ if (H5Tset_size(complex_id, size)<0) goto error;
+ if (H5Tinsert(complex_id, "imaginary", offset,
+ H5T_NATIVE_DOUBLE)<0) goto error;
+
+ /* Increase and decrease the size. */
+ if((size+=H5Tget_size(H5T_NATIVE_DOUBLE))<0) goto error;
+ if (H5Tset_size(complex_id, size)<0) goto error;
+
+ if((size-=H5Tget_size(H5T_NATIVE_DOUBLE))<0) goto error;
+ if (H5Tset_size(complex_id, size)<0) goto error;
+
+ /* Verify the size */
+ if((new_size=H5Tget_size(complex_id))<0) goto error;
+ if(new_size!=size) goto error;
+
+ /* Tries to cut last member. Supposed to fail. */
+ size--;
+ H5E_BEGIN_TRY {
+ H5Tset_size(complex_id, size);
+ } H5E_END_TRY;
+
+ if (H5Tclose (complex_id)<0) goto error;
+ PASSED();
+ return 0;
+
+ error:
+ return 1;
+}
+
+
+/*-------------------------------------------------------------------------
* Function: test_query
*
* Purpose: Tests query functions of compound and enumeration types.
@@ -5216,6 +5287,7 @@ main(void)
nerrors += test_compound_9();
nerrors += test_compound_10();
nerrors += test_compound_11();
+ nerrors += test_compound_12();
nerrors += test_conv_int ();
nerrors += test_conv_enum_1();
nerrors += test_conv_enum_2();