summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dumpgentest.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-11-18 16:38:11 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-11-18 16:38:11 (GMT)
commit0105a3b97cabccd3463c82c22da7e3f4d23c2b05 (patch)
tree9b0002e531446227f62b929adba84b9bfbcacc8a /tools/h5dump/h5dumpgentest.c
parent02fe47462b798e7f212f09fe65f022965ce4b365 (diff)
downloadhdf5-0105a3b97cabccd3463c82c22da7e3f4d23c2b05.zip
hdf5-0105a3b97cabccd3463c82c22da7e3f4d23c2b05.tar.gz
hdf5-0105a3b97cabccd3463c82c22da7e3f4d23c2b05.tar.bz2
[svn-r6099]
Purpose: bug fix. Description: h5dump cannot dump data and datatype for VL string. Platforms tested: eirene, arabica Misc. update: MANIFEST, RELEASE.txt
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r--tools/h5dump/h5dumpgentest.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 8f6e3bc..f0e9515 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -63,6 +63,7 @@
#define FILE35 "tfamily%05d.h5"
#define FILE36 "tmulti"
#define FILE37 "tlarge_objname.h5"
+#define FILE38 "tvlstr.h5"
#define LENSTR 50
#define LENSTR2 11
@@ -108,6 +109,9 @@ typedef struct s1_t {
#define ARRAY3_DIM1 6
#define ARRAY3_DIM2 3
+/* VL string datatype name */
+#define VLSTR_TYPE "vl_string_type"
+
static void gent_group(void)
{
hid_t fid, group;
@@ -2838,6 +2842,55 @@ static void gent_large_objname(void)
H5Fclose(fid);
}
+static void gent_vlstr(void)
+{
+ const char *wdata[SPACE1_DIM1]= {
+ "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
+ "conceived in liberty and dedicated to the proposition that all men are created equal.",
+ "Now we are engaged in a great civil war,",
+ "testing whether that nation or any nation so conceived and so dedicated can long endure."
+ }; /* Information to write */
+ char *string_att= "This is the string for the attribute";
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset, root; /* Dataset ID */
+ hid_t sid1, dataspace;/* Dataspace ID */
+ hid_t tid1, att; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE38, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+
+ /* Create a VL string datatype to refer to */
+ tid1 = H5Tcopy (H5T_C_S1);
+ H5Tset_size (tid1,H5T_VARIABLE);
+
+ /* Create a dataset and write VL string to it. */
+ dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
+ H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata);
+ H5Dclose(dataset);
+
+ /* Create a named VL string type. Change padding of datatype */
+ H5Tset_strpad(tid1, H5T_STR_NULLPAD);
+ H5Tcommit(fid1, "vl_string_type", tid1);
+
+ /* Create an group attribute of VL string type */
+ root = H5Gopen(fid1, "/");
+ dataspace = H5Screate(H5S_SCALAR);
+
+ att = H5Acreate(root, "test_scalar", tid1, dataspace, H5P_DEFAULT);
+ H5Awrite(att, tid1, &string_att);
+
+ /* Close */
+ H5Tclose(tid1);
+ H5Sclose(sid1);
+ H5Sclose(dataspace);
+ H5Aclose(att);
+ H5Gclose(root);
+ H5Fclose(fid1);
+}
+
int main(void)
{
gent_group();
@@ -2888,6 +2941,7 @@ int main(void)
gent_multi();
gent_large_objname();
+ gent_vlstr();
return 0;
}