summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dumpgentest.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-05 21:19:38 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-05 21:19:38 (GMT)
commit71f0aeff2a564ed6cc7a22be09b0a698f9e12e13 (patch)
tree03c0a3a388e34b0efa97d11904a9057e75065617 /tools/h5dump/h5dumpgentest.c
parent3bc05bfd2470fb0ae2301d511e48b708493a8e6b (diff)
downloadhdf5-71f0aeff2a564ed6cc7a22be09b0a698f9e12e13.zip
hdf5-71f0aeff2a564ed6cc7a22be09b0a698f9e12e13.tar.gz
hdf5-71f0aeff2a564ed6cc7a22be09b0a698f9e12e13.tar.bz2
[svn-r7540] Purpose:
Bug fixes and code cleanup Description: Changes to h5dump code: - Dump shared datatypes for any class of datatype, not just compound datatypes. - Cleaned up formatting to greatly reduce the amount of trailing whitespace emitted in output. Also removed some spurious blank lines from named datatype output. Added code to generate named datatype attribute test file. Added tests for dumping named datatypes in attributes for both DDL and XML output. Platforms tested: FreeBSD 4.9 (sleipnir) h5committest
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r--tools/h5dump/h5dumpgentest.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index b2edb8d..0356b2b 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -67,6 +67,7 @@
#define FILE39 "tchar.h5"
#define FILE40 "tattr2.h5"
#define FILE41 "tcompound_complex.h5"
+#define FILE42 "tnamed_dtype_attr.h5"
/* prototypes */
@@ -138,6 +139,12 @@ typedef struct s1_t {
#define F41_ARRAY_DIMd2 6
#define F41_ARRAY_DIMf 10
+/* "File 42" macros */
+/* Name of dataset to create in datafile */
+#define F42_DSETNAME "Dataset"
+#define F42_TYPENAME "Datatype"
+#define F42_ATTRNAME "Attribute"
+
static void gent_group(void)
{
hid_t fid, group;
@@ -4180,6 +4187,66 @@ static void gent_compound_complex(void)
}
+static void gent_named_dtype_attr(void)
+{
+ hid_t file_id;
+ hid_t dset_id;
+ hid_t space_id;
+ hid_t type_id;
+ hid_t attr_id;
+ int data=8;
+ herr_t ret;
+
+ /* Create a file */
+ file_id=H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(file_id>0);
+
+ /* Create a datatype to commit and use */
+ type_id=H5Tcopy(H5T_NATIVE_INT);
+ assert(type_id>0);
+
+ /* Commit datatype to file */
+ ret=H5Tcommit(file_id,F42_TYPENAME,type_id);
+ assert(ret>=0);
+
+ /* Create dataspace for dataset */
+ space_id=H5Screate(H5S_SCALAR);
+ assert(space_id>0);
+
+ /* Create dataset */
+ dset_id=H5Dcreate(file_id,F42_DSETNAME,type_id,space_id,H5P_DEFAULT);
+ assert(dset_id>0);
+
+ /* Create attribute on dataset */
+ attr_id=H5Acreate(dset_id,F42_ATTRNAME,type_id,space_id,H5P_DEFAULT);
+ assert(dset_id>0);
+
+ /* Write data into the attribute */
+ ret=H5Awrite(attr_id,H5T_NATIVE_INT,&data);
+ assert(ret>=0);
+
+ /* Close attribute */
+ ret=H5Aclose(attr_id);
+ assert(ret>=0);
+
+ /* Close dataset */
+ ret=H5Dclose(dset_id);
+ assert(ret>=0);
+
+ /* Close dataspace */
+ ret=H5Sclose(space_id);
+ assert(ret>=0);
+
+ /* Close datatype */
+ ret=H5Tclose(type_id);
+ assert(ret>=0);
+
+ /* Close file */
+ ret=H5Fclose(file_id);
+ assert(ret>=0);
+}
+
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -4244,5 +4311,7 @@ int main(void)
gent_compound_complex();
+ gent_named_dtype_attr();
+
return 0;
}