summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2005-02-09 15:54:44 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2005-02-09 15:54:44 (GMT)
commit86c18b7e4f2fd322b3571a9050c4eb051027391a (patch)
tree314568f5c303132a82605ade164897bc0eb88f60 /test
parente1ef99ed1dbbaa57428cc8cbc8513e6adf6ae5c6 (diff)
downloadhdf5-86c18b7e4f2fd322b3571a9050c4eb051027391a.zip
hdf5-86c18b7e4f2fd322b3571a9050c4eb051027391a.tar.gz
hdf5-86c18b7e4f2fd322b3571a9050c4eb051027391a.tar.bz2
[svn-r9966] Purpose: Bug fix
Description: H5Tget_member_value didn't return correct value if called after H5Tenum_valueof. It's because there's a sorting on the members of enum type in H5Tenum_valueof which changed the order of members. Solution: Made a copy of original type and do sorting on it to protect the original order. Platforms tested: fuss; tested v1.6 with h5committest Misc. update: RELEASE.txt
Diffstat (limited to 'test')
-rw-r--r--test/dtypes.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 77254ea..c119eb7 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -2267,7 +2267,10 @@ test_compound_12(void)
* Thursday, April 4, 2002
*
* Modifications:
- *
+ * Raymond Lu
+ * Wednesday, Febuary 9, 2005
+ * Added test for H5Tenum_valueof, H5Tenum_nameof, and
+ * H5Tget_member_value.
*-------------------------------------------------------------------------
*/
static int
@@ -2283,6 +2286,7 @@ test_query(void)
char filename[1024];
char compnd_type[]="Compound_type", enum_type[]="Enum_type";
short enum_val;
+ char enum_name[16];
TESTING("query functions of compound and enumeration types");
@@ -2324,27 +2328,27 @@ test_query(void)
printf("Can't create enumerate type\n");
goto error;
} /* end if */
- if(H5Tenum_insert(tid2, "RED", (enum_val=0,&enum_val))<0) {
+ if(H5Tenum_insert(tid2, "RED", (enum_val=10,&enum_val))<0) {
H5_FAILED();
printf("Can't insert field into enumeration type\n");
goto error;
} /* end if */
- if(H5Tenum_insert(tid2, "GREEN", (enum_val=1,&enum_val))<0) {
+ if(H5Tenum_insert(tid2, "GREEN", (enum_val=11,&enum_val))<0) {
H5_FAILED();
printf("Can't insert field into enumeration type\n");
goto error;
} /* end if */
- if(H5Tenum_insert(tid2, "BLUE", (enum_val=2,&enum_val))<0) {
+ if(H5Tenum_insert(tid2, "BLUE", (enum_val=12,&enum_val))<0) {
H5_FAILED();
printf("Can't insert field into enumeration type\n");
goto error;
} /* end if */
- if(H5Tenum_insert(tid2, "ORANGE", (enum_val=3,&enum_val))<0) {
+ if(H5Tenum_insert(tid2, "ORANGE", (enum_val=13,&enum_val))<0) {
H5_FAILED();
printf("Can't insert field into enumeration type\n");
goto error;
} /* end if */
- if(H5Tenum_insert(tid2, "YELLOW", (enum_val=4,&enum_val))<0) {
+ if(H5Tenum_insert(tid2, "YELLOW", (enum_val=14,&enum_val))<0) {
H5_FAILED();
printf("Can't insert field into enumeration type\n");
goto error;
@@ -2362,7 +2366,7 @@ test_query(void)
goto error;
} /* end if */
- /* Query member number and member index by name, for enumeration type. */
+ /* Query member number and member index by member name, for enumeration type. */
if(H5Tget_nmembers(tid2)!=5) {
H5_FAILED();
printf("Can't get member number\n");
@@ -2422,7 +2426,7 @@ test_query(void)
goto error;
} /* end if */
- /* Query member number and member index by name, for enumeration type */
+ /* Query member number and member index by member name, for enumeration type */
if(H5Tget_nmembers(tid2)!=5) {
H5_FAILED();
printf("Can't get member number\n");
@@ -2434,6 +2438,43 @@ test_query(void)
goto error;
} /* end if */
+ /* Query member value by member name, for enumeration type */
+ if(H5Tenum_valueof (tid2, "ORANGE", &enum_val)<0) {
+ H5_FAILED();
+ printf("Can't get value for enumerate member\n");
+ goto error;
+ } /* end if */
+ if(enum_val!=13) {
+ H5_FAILED();
+ printf("Incorrect value for enum member\n");
+ goto error;
+ } /* end if */
+
+ /* Query member value by member index, for enumeration type */
+ if(H5Tget_member_value (tid2, 2, &enum_val)<0) {
+ H5_FAILED();
+ printf("Can't get value for enum member\n");
+ goto error;
+ } /* end if */
+ if(enum_val!=12) {
+ H5_FAILED();
+ printf("Incorrect value for enum member\n");
+ goto error;
+ } /* end if */
+
+ /* Query member name by member value, for enumeration type */
+ enum_val = 14;
+ if(H5Tenum_nameof(tid2, &enum_val, enum_name, 16)<0) {
+ H5_FAILED();
+ printf("Can't get name for enum member\n");
+ goto error;
+ } /* end if */
+ if(strcmp("YELLOW", enum_name)) {
+ H5_FAILED();
+ printf("Incorrect name for enum member\n");
+ goto error;
+ } /* end if */
+
/* Close data type and file */
if(H5Tclose(tid1)<0) {
H5_FAILED();